From 7319ab1ce998a7d13f0192a4ccaf92d4a02929f8 Mon Sep 17 00:00:00 2001
From: licp <lichunping@guanfang.com.cn>
Date: 星期三, 11 十二月 2024 14:33:43 +0800
Subject: [PATCH] 电路试验上传文件报错
---
src/components/tool/value-table.vue | 50 ++++++++++++++++++++++++++++++++++++++++++--------
1 files changed, 42 insertions(+), 8 deletions(-)
diff --git a/src/components/tool/value-table.vue b/src/components/tool/value-table.vue
index 200cd41..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%;
@@ -116,9 +120,9 @@
<el-table ref="eltable" :data="tableData" style="width: 100%;" height="100%" tooltip-effect="dark" border
@selection-change="selectChange" @select="select" v-loading="loading" @sort-change="sortChange"
@row-click="rowClick" :show-summary="data.countFleid!=undefined && data.countFleid.length > 0"
- :summary-method="getSummaries" :row-class-name="tableRowClassName" :row-key="record=>record.id"
+ :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: {
@@ -358,6 +357,12 @@
},
tableRowClassName: {
type: Function
+ },
+ rowKey: {
+ type: String,
+ default: ()=>{
+ return 'id'
+ }
},
url: {
type: String,
@@ -497,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