feat: 自定义表格

This commit is contained in:
wf 2024-06-03 12:55:19 +08:00
parent 73e8c1e1fe
commit 5765b67c2b

View File

@ -157,7 +157,7 @@
<script setup lang="ts">
import { deepClone } from "@/utils";
// import Sortable from "sortablejs";
import Sortable from "sortablejs";
const formData = reactive({
form: {
serial: "",
@ -229,6 +229,8 @@ const columns = ref([
checked: true
}
]);
// columns
//
const deepColumns = () => {
columnsShow.value = deepClone(columns.value);
};
@ -370,20 +372,34 @@ const onCheckbox = (checked: any, row: any, index: any) => {
};
//
const popupVisibleChange = (visible: boolean) => {
console.log("文字气泡窗打开?", visible);
// if (visible) {
// nextTick(() => {
// const el = document.getElementById("tableSetting") as HTMLElement;
// new Sortable(el, {
// onEnd(e: any) {
// const { oldIndex, newIndex } = e;
// console.log("", oldIndex, newIndex);
// // exchangeArray(cloneColumns.value, oldIndex, newIndex);
// // exchangeArray(showColumns.value, oldIndex, newIndex);
// }
// });
// });
// }
if (visible) {
nextTick(() => {
// dom
const el = document.getElementById("tableSetting") as HTMLElement;
new Sortable(el, {
onEnd(e: any) {
//
const { oldIndex, newIndex } = e;
console.log("移动",columns.value, columnsShow.value);
// columnscolumns
exchangeArray(columns.value, oldIndex, newIndex);
exchangeArray(columnsShow.value, oldIndex, newIndex);
}
});
});
}
};
//
const exchangeArray = (columns: Array<any>, oldIndex: number, newIndex: number) => {
//
let temp = columns[newIndex];
// newIndexoldIndex
columns[newIndex] = columns[oldIndex];
// newIndex
columns[oldIndex] = temp;
};
</script>