qymljy 1 anno fa
parent
commit
0cf14c927d

+ 11 - 0
package-lock.json

@@ -29,6 +29,7 @@
         "nprogress": "^0.2.0",
         "print-js": "^1.6.0",
         "script-loader": "^0.7.2",
+        "sortablejs": "^1.15.2",
         "viewerjs": "^1.11.6",
         "vue": "^2.6.14",
         "vue-countupjs": "^1.0.0",
@@ -13299,6 +13300,11 @@
         "websocket-driver": "^0.7.4"
       }
     },
+    "node_modules/sortablejs": {
+      "version": "1.15.2",
+      "resolved": "https://registry.npmmirror.com/sortablejs/-/sortablejs-1.15.2.tgz",
+      "integrity": "sha512-FJF5jgdfvoKn1MAKSdGs33bIqLi3LmsgVTliuX6iITj834F+JRQZN90Z93yql8h0K2t0RwDPBmxwlbZfDcxNZA=="
+    },
     "node_modules/source-map": {
       "version": "0.5.7",
       "resolved": "https://registry.npmmirror.com/source-map/-/source-map-0.5.7.tgz",
@@ -27066,6 +27072,11 @@
         "websocket-driver": "^0.7.4"
       }
     },
+    "sortablejs": {
+      "version": "1.15.2",
+      "resolved": "https://registry.npmmirror.com/sortablejs/-/sortablejs-1.15.2.tgz",
+      "integrity": "sha512-FJF5jgdfvoKn1MAKSdGs33bIqLi3LmsgVTliuX6iITj834F+JRQZN90Z93yql8h0K2t0RwDPBmxwlbZfDcxNZA=="
+    },
     "source-map": {
       "version": "0.5.7",
       "resolved": "https://registry.npmmirror.com/source-map/-/source-map-0.5.7.tgz",

+ 1 - 0
package.json

@@ -30,6 +30,7 @@
     "nprogress": "^0.2.0",
     "print-js": "^1.6.0",
     "script-loader": "^0.7.2",
+    "sortablejs": "^1.15.2",
     "viewerjs": "^1.11.6",
     "vue": "^2.6.14",
     "vue-countupjs": "^1.0.0",

+ 5 - 2
src/WebsiteManagement/consultManage/modules/classManage.vue

@@ -12,7 +12,7 @@
       <div class="drawer__panel" style="margin-bottom: 0!important;">
         <el-button style="margin-bottom: 10px" type="primary" size="small" @click="addClass">新增分类</el-button>
         <tableNewLayout ref="tableRef" :checkbox="false" :custom="true" :data="list" :layout="tablecols"
-                        :opwidth="200" :width="true" height="calc(100vh - 210px)">
+                        :opwidth="200" :width="true" height="calc(100vh - 210px)" @rowSort="rowSort">
           <template v-slot:customcol="scope">
             <div v-if="scope.column.columnname === 'classname'">
               <el-input v-if="sat_notice === scope.column.data.sat_notice_classid" size="mini" v-model="scope.column.data.classname" placeholder="输入分类名称"></el-input>
@@ -86,7 +86,7 @@ export default {
       this.list.unshift({
         "sat_notice_classid":0,     //sat_notice_classid<=0时 为新增
         "classname": "",
-        "sequence":1,
+        "sequence":this.list.length + 1,
         "isused":1
       })
     },
@@ -151,6 +151,9 @@ export default {
     },
     closeDrawer(){
       this.drawer = false
+    },
+    rowSort(data){
+      this.list = data
     }
   },
   created() {

+ 25 - 1
src/components/dynamic-newTable/index2.vue

@@ -2,7 +2,9 @@
   <div>
     <!-- :header-cell-style="{background:'#EEEEEE',color:'#333'}" -->
     <el-table ref="table" :row-class-name="tableClassName" highlight-current-row :data="data"  size="mini"  :height="height ? height : data.length <= 5?'280px':'calc(100vh - 268px)'"  @row-click="rowClick" :style="{width:'100%',minHeight:minHeight?minHeight:''}" :header-cell-style="{background:'#fafafafa',height:'40px',color:'#000000',fontSize:'12px'}"
-              :cell-style="{height:'40px',color:'#666666',fontWeight:'400'}" border @selection-change="selectionChange">
+              :cell-style="{height:'40px',color:'#666666',fontWeight:'400'}" border @selection-change="selectionChange"
+              row-key="id"
+            >
       <el-table-column
           type="selection"
           width="35" fixed v-if="checkbox">
@@ -28,6 +30,7 @@
 
 <script>
 import {mapGetters} from "vuex"
+import Sortable from 'sortablejs'
 export default {
   /*
     layout:表结构数据;
@@ -39,6 +42,10 @@ export default {
   data () {
     return {
       list:[],
+      isCopy:true,
+      isRowSort:true,
+      highlightCurrentRow:[],
+      isShowTreeStyle:true
     }
   },
   computed:{
@@ -67,9 +74,26 @@ export default {
           this.$refs.table.doLayout()
         })
       }
+    },
+    initSort() {
+      console.log('执行了换个位置')
+      if (!this.isRowSort) return
+      const el = this.$refs['table'].$el.querySelector('.el-table__body-wrapper > table > tbody')
+      new Sortable(el, {
+        animation: 150, // 动画
+        onEnd: evt => {
+          console.log(evt,'evt11')
+          const curRow = this.data.splice(evt.oldIndex, 1)[0]
+          console.log(curRow,'curRow22')
+          this.data.splice(evt.newIndex, 0, curRow)
+          console.log(this.data,'表格数据')
+          this.$emit('rowSort', this.data)
+        }
+      })
     }
   },
   mounted () {
+    this.initSort()
   }
 }
 

+ 3 - 0
src/main.js

@@ -31,6 +31,7 @@ import '@/style/theme/font-icon/iconfont.css'
 
 
 
+
 // import {hiPrintPlugin} from './index'
 // Vue.use(hiPrintPlugin)
 Vue.prototype.$api = api
@@ -49,6 +50,8 @@ Vue.prototype.$axios = axios
 
 
 
+
+
 Vue.prototype.tableHieght = 'calc(100vh - 302px)'
 
 Vue.config.productionTip = false;