对讲排序备份

之前用的是通过css控制位置,然后支持拖动,
现在使用flex布局,拖动排序即可
在这里插入图片描述

 //添加排序对讲窗口
      SortVideoTable(sortIntercomBoxDatas) {

        this.intercomBoxDatas.push(sortIntercomBoxDatas);
        /*初始化jquery*/
        /* $(document).ready(() => {
           /!*lua中的一个函数,math.ceil(x)返回大于等于参数x的最小整数,即对浮点数向上取整.*!/
           for (var i = 1; i <= this.intercomBoxDatas.length; i++) {

             if (window.screen.width == 1366) {
               var css = {
                 left: (Math.ceil((i) % 5.1) - 1) * 18 + 4 + '%',
                 top: (Math.ceil((i + 1) / 6.1) - 1) * 150 + 10,
               };
             } else if (window.screen.width == 1920 && window.screen.height == 1280) {
               var css = {
                 left: (Math.ceil((i) % 6.1) - 1) * 1 + 1 + '%',
                 // left: (Math.ceil((i) % 6.1) -1) * 1 + 1 + 'px',
                 top: (Math.ceil((i + 1) / 7.1) - 1) * 20 + 20,
               };
             } else {
               /!*var css = {
                 left: (Math.ceil((i) % 5.1) - 1) * 16.5 + 4 + '%',
                 top: (Math.ceil((i + 1) / 6.1) - 1) * 210 + 10,
               };*!/
               var css = {
                 left: (Math.ceil((i) % 6.1) - 1) * 1 + 1 + '%',
                 // left: (Math.ceil((i) % 6.1) -1) * 1 + 1 + 'px',
                 top: (Math.ceil((i + 1) / 7.1) - 1) * 20 + 20,
               };
             }
             var a = '#intercomBox' + i;
             var b = '#intercomBox-up' + i;
             // $(a).Tdrag({
             //       scope: '.intercomBoxContainer',
             //       handle: b,//手柄,
             //       pos: true,
             //       dragChange: true,
             //       changeMode: 'sort',
             //     },
             // );
             $(a).css(css);
           }

         });*/
        const tbody = document.querySelector('.intercomBox');
        /* Sortable.create(tbody, {
           onEnd({ newIndex, oldIndex }) {
             console.log(newIndex);
             const currRow = _this.intercomBoxDatas.splice(oldIndex, 1)[0]
             _this.intercomBoxDatas.splice(newIndex, 0, currRow)
           }
         })*/
        /*this.sortable = Sortable.create(tbody, {
          animation: 180,
          delay: 0,
          onEnd: evt => {
            const oldItem = this.intercomBoxDatas[evt.oldIndex]
            this.intercomBoxDatas.splice(evt.oldIndex, 1)
            this.intercomBoxDatas.splice(evt.newIndex, 0, oldItem)
            console.log(evt.oldIndex,evt.newIndex);
          }
        })*/
        var that = this;
   setTimeout(()=> {
          var el = document.getElementById('intercomBoxSortID');
          this.sortable = Sortable.create(el, {
            onEnd: (evt)=> {
              let itemEl = evt.item;
              let oldIndex = evt.oldIndex;
              let newIndex = evt.newIndex;
              let temp = this.intercomBoxDatas[oldIndex];
              if (oldIndex < newIndex) {
                for (var i = oldIndex; i < newIndex; i++) {
                  this.intercomBoxDatas[i] = this.intercomBoxDatas[i + 1];
                }
              } else if (oldIndex > newIndex) {
                for (var i = oldIndex; i > newIndex; i--) {
                  this.intercomBoxDatas[i] = this.intercomBoxDatas[i - 1];
                }
              }
              this.intercomBoxDatas[newIndex] = temp;
            },
          });
        }, 100);
      }
      ,
      //默认排序对讲窗口
      SortVideoTableNomal() {
        /*初始化jquery*/
        /* $(document).ready(() => {
           /!*lua中的一个函数,math.ceil(x)返回大于等于参数x的最小整数,即对浮点数向上取整.*!/
           for (var i = 1; i <= this.intercomBoxDatas.length; i++) {
             /!*   var css = {
                  left: (Math.ceil((i) % 5.1) - 1) * 19 + 4 + '%',
                  top: (Math.ceil((i + 1) / 6.1) - 1) * 100 + 10,
                };*!/
             if (window.screen.width == 1366) {
               var css = {
                 left: (Math.ceil((i) % 5.1) - 1) * 18 + 4 + '%',
                 top: (Math.ceil((i + 1) / 6.1) - 1) * 150 + 10,
               };
             } else if (window.screen.width == 1920 && window.screen.height == 1280) {
               var css = {
                 left: (Math.ceil((i) % 6.1) - 1) * 1 + 1 + '%',
                 top: (Math.ceil((i + 1) / 7.1) - 1) * 20 + 20,
               };
             } else {
               /!*var css = {
                 left: (Math.ceil((i) % 5.1) - 1) * 16.5 + 4 + '%',
                 top: (Math.ceil((i + 1) / 6.1) - 1) * 210 + 10,
               };*!/
               var css = {
                 left: (Math.ceil((i) % 6.1) - 1) * 1 + 1 + '%',
                 top: (Math.ceil((i + 1) / 7.1) - 1) * 20 + 20,
               };
             }
             var a = '#intercomBox' + i;
             var b = '#intercomBox-up' + i;
             // $(a).Tdrag({
             //       scope: '.intercomBoxContainer',
             //       handle: b,//手柄,
             //       pos: true,
             //       dragChange: true,
             //       changeMode: 'sort',
             //     },
             // );
             $(a).css(css);
           }
         });*/
      }
      ,
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值