From 811bbc3feb318238214d022cb3a7458176f28e55 Mon Sep 17 00:00:00 2001 From: licp <lichunping@guanfang.com.cn> Date: 星期一, 02 九月 2024 17:17:18 +0800 Subject: [PATCH] 新增插队、扫码枪等功能 --- src/components/tool/value-table.vue | 42 +++++++++++++++++++++++++++++++++++------- 1 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/components/tool/value-table.vue b/src/components/tool/value-table.vue index 1892627..4d7ee4a 100644 --- a/src/components/tool/value-table.vue +++ b/src/components/tool/value-table.vue @@ -4,6 +4,10 @@ height: 100%; overflow-y: auto; } + >>>.el-table__row { + cursor: move; + position: relative; + } .table { width: 100%; @@ -118,7 +122,7 @@ @row-click="rowClick" :show-summary="data.countFleid!=undefined && data.countFleid.length > 0" :summary-method="getSummaries" :row-class-name="tableRowClassName" :row-key="record=>record[rowKey]" :current-row-key="data.currentId" :highlight-current-row="data.highlight===undefined||data.highlight" - :span-method="spanMethod" :key="specialKey"> + :span-method="spanMethod" :key="specialKey" :class="{sortable:data.sortable}"> <el-table-column type="selection" :width="selectionWidth" v-if="data.showSelect" :key="Math.random()"> </el-table-column> <el-table-column type="index" align="center" label="搴忓彿" :width="selectionWidth" v-if="data.isIndex" :key="Math.random()"> @@ -332,12 +336,7 @@ </template> <script> - import { - Page - } from 'iview'; - import { - data - } from 'jquery'; + import Sortable from 'sortablejs'; export default { props: { selectionWidth: { @@ -503,8 +502,37 @@ 'token': sessionStorage.getItem('token') } this.specialKey = this.specialKey+Math.random()*100; + // 鏄惁鍙嫋鍔ㄥ垪琛�--姝ゅ姛鑳芥殏鏃舵湭瀹炵幇 + if(this.data.sortable){ + this.$nextTick(() => { + this.initializeSortable() + }) + } }, methods: { + initializeSortable() { + let className =".el-table__body-wrapper > table > tbody"; + const table= document.querySelector(className); + const self = this + Sortable.create(table, { + animation: 150, //鍔ㄧ敾鏃堕暱 + handle: ".el-table__row", //鍙嫋鎷藉尯鍩焎lass + onEnd({ newIndex, oldIndex }) { + console.log(3333,newIndex, oldIndex) + const movedItem = this.tableData[oldIndex]; + this.tableData.splice(oldIndex, 1); + this.tableData.splice(newIndex, 0, movedItem); + } + }) + }, + getUpdatedOrder() { + // 鏍规嵁鎷栨嫿鍚庣殑椤哄簭鑾峰彇鏇存柊鐨勬暟鎹� + // 杩欓噷闇�瑕佸疄鐜颁綘鐨勯�昏緫 + }, + updateTableData(newOrder) { + // 鏍规嵁鏂扮殑椤哄簭鏇存柊琛ㄦ牸鏁版嵁 + // 杩欓噷闇�瑕佸疄鐜颁綘鐨勯�昏緫 + }, rowspan(spanArr, position, spanName) { this.tableData.forEach((item, index) => { if (index === 0) { -- Gitblit v1.9.3