<template>     <el-card v-loading="fullscreenLoading">         <el-table                 :data="tableOptions.data"                 border                 size="small"                 row-key='roleId'                 ref="table"                 @cell-mouse-enter.once='rowDrop'         >             <el-table-column                     prop="sort"                     label="拖拽区域"             >                 <template slot-scope="scope">                     <el-button type="text" size="small" class="handle">按住拖拽</el-button>                 </template>             </el-table-column>             <el-table-column                     v-for="item of column"                     :key="item.prop"                     :prop="item.prop"                     :label="item.label"                     :width="item.width"                     :fixed="item.fixed"             />         </el-table>         <el-pagination                 background                 :hide-on-single-page="paginationOptions.showPage"                 :layout="paginationOptions.layout"                 :page-sizes="paginationOptions.pageSizes"                 :total="paginationOptions.total"                 :page-size="paginationOptions.pageSize"                 :current-page="paginationOptions.currentPage"                 @size-change="handleSizeChange"                 @current-change="handleCurrentChange"         />     </el-card> </template> <script>   import Sortable from 'sortablejs';   import table from "@/mixins/table"
    export default {     name: 'TableDraggable',     mixins: [table],     props: {},     data() {       return {         column: [           {             prop: "roleId",             label: "序号",             width: 100,           },           {             prop: 'roleName',             label: "角色名称",           },           {             prop: "createTime",             label: "创建时间",           },           {             prop: "roleId",             label: "序号",             width: 100,           },           {             prop: 'edit',             label: "编辑",             width: 180,             fixed: 'right'           },         ],         fullscreenLoading: true,         paginationOptions: {           pageSizes: [10, 20, 30, 40],         },       }     },     watch: {       'tableOptions.data': {         deep: true,         handler: function (newData) {                    }       }     },     methods: {              rowDrop() {         const tbody = this.$refs.table.$el.querySelector('.el-table__body-wrapper tbody');         const _this = this;         Sortable.create(tbody, {           handle: '.handle',           animation: 150,           onChoose() {                          _this.column[_this.column.length - 1].fixed = false           },           onUnchoose: function (evt) {                          _this.column[_this.column.length - 1].fixed = 'right'
            },           onEnd({newIndex, oldIndex}) {                          const currRow = _this.tableOptions.data.splice(oldIndex, 1)[0]             _this.tableOptions.data.splice(newIndex, 0, currRow)           }         })       }     }   } </script>
  <style type="text/scss" lang="scss" scoped>     .handle {         cursor: move     }
      ::v-deep .hover-row > td {         background-color: #fff !important;     }
      ::v-deep .sortable-chosen > td {         // 拖动的样式         background-color: #eff2f6 !important;     }
      ::v-deep .el-table--enable-row-hover .el-table__body tr:hover > td {         // 修复拖拽的时候hover的不消失的问题         background-color: #fff;     } </style>
   |