作者 RuoYi

添加handle控制允许拖动的元素

@@ -6,7 +6,7 @@ @@ -6,7 +6,7 @@
6 </el-tab-pane> 6 </el-tab-pane>
7 <el-tab-pane label="字段信息" name="cloum"> 7 <el-tab-pane label="字段信息" name="cloum">
8 <el-table ref="dragTable" :data="cloumns" row-key="columnId" :max-height="tableHeight"> 8 <el-table ref="dragTable" :data="cloumns" row-key="columnId" :max-height="tableHeight">
9 - <el-table-column label="序号" type="index" min-width="5%" /> 9 + <el-table-column label="序号" type="index" min-width="5%" class-name="allowDrag" />
10 <el-table-column 10 <el-table-column
11 label="字段列名" 11 label="字段列名"
12 prop="columnName" 12 prop="columnName"
@@ -203,6 +203,7 @@ export default { @@ -203,6 +203,7 @@ export default {
203 mounted() { 203 mounted() {
204 const el = this.$refs.dragTable.$el.querySelectorAll(".el-table__body-wrapper > table > tbody")[0]; 204 const el = this.$refs.dragTable.$el.querySelectorAll(".el-table__body-wrapper > table > tbody")[0];
205 const sortable = Sortable.create(el, { 205 const sortable = Sortable.create(el, {
  206 + handle: ".allowDrag",
206 onEnd: evt => { 207 onEnd: evt => {
207 const targetRow = this.cloumns.splice(evt.oldIndex, 1)[0]; 208 const targetRow = this.cloumns.splice(evt.oldIndex, 1)[0];
208 this.cloumns.splice(evt.newIndex, 0, targetRow); 209 this.cloumns.splice(evt.newIndex, 0, targetRow);