|
|
@@ -77,7 +77,7 @@
|
|
|
</template>
|
|
|
|
|
|
<script setup lang="ts">
|
|
|
- import { ref, onMounted, reactive, h, watch, computed } from 'vue';
|
|
|
+ import { ref, onMounted, reactive, h, computed } from 'vue';
|
|
|
import { Plus } from '@element-plus/icons-vue';
|
|
|
import { BasicTable, BasicColumn } from '@/components/Table';
|
|
|
import { ElMessageBox } from 'element-plus';
|
|
|
@@ -88,11 +88,11 @@
|
|
|
import { DATA_LEVEL, DrawerType, ENABLED } from './constant';
|
|
|
import {
|
|
|
colomns,
|
|
|
- dataSourceWithParent,
|
|
|
updateSerials,
|
|
|
findItemLevel,
|
|
|
removeParent,
|
|
|
flattenCodes,
|
|
|
+ getParent,
|
|
|
} from './use-method.tsx';
|
|
|
import {
|
|
|
ComAddDatas,
|
|
|
@@ -150,19 +150,12 @@
|
|
|
|
|
|
onMounted(() => {
|
|
|
//添加父级,主要用于排序功能
|
|
|
- dataSourceWithParent(tableData.value, null);
|
|
|
+ //dataSourceWithParent(tableData.value, null);
|
|
|
+
|
|
|
//获取tableData数据
|
|
|
getSceneDetail();
|
|
|
});
|
|
|
|
|
|
- //增加parent用于排序
|
|
|
- watch(
|
|
|
- () => tableData.value,
|
|
|
- () => {
|
|
|
- dataSourceWithParent(tableData.value, null);
|
|
|
- },
|
|
|
- );
|
|
|
-
|
|
|
function onCheckedRow(rowKeys) {
|
|
|
console.log(rowKeys);
|
|
|
}
|
|
|
@@ -375,20 +368,19 @@
|
|
|
//向上排序
|
|
|
const rowUp = (row) => {
|
|
|
if (row.parent) {
|
|
|
- const parentIndex = row.parent.children!.indexOf(row);
|
|
|
- row.parentIndex = parentIndex;
|
|
|
+ const parentIndex = row.parent.children!.findIndex((item) => item.id === row.id);
|
|
|
if (parentIndex > 0) {
|
|
|
const previousRow = row.parent.children![parentIndex - 1];
|
|
|
+ const targetParent = getParent(tableData.value, previousRow.parent.id);
|
|
|
// 进行交换位置
|
|
|
- row.parent.children!.splice(parentIndex - 1, 2, row, previousRow);
|
|
|
+ targetParent.children!.splice(parentIndex - 1, 2, row, previousRow);
|
|
|
}
|
|
|
} else {
|
|
|
- const index = tableData.value.indexOf(row);
|
|
|
+ const index = tableData.value.findIndex((item) => item.id === row.id);
|
|
|
if (index > 0) {
|
|
|
tableData.value.splice(index - 1, 2, row, tableData.value[index - 1]);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
tableData.value = updateSerials(tableData.value);
|
|
|
sortSceneList(removeParent(tableData.value))
|
|
|
.then(() => {
|
|
|
@@ -402,14 +394,15 @@
|
|
|
//向下排序
|
|
|
const rowDown = (row) => {
|
|
|
if (row.parent) {
|
|
|
- const parentIndex = row.parent.children!.indexOf(row);
|
|
|
+ const parentIndex = row.parent.children!.findIndex((item) => item.id === row.id);
|
|
|
if (parentIndex < row.parent.children?.length - 1) {
|
|
|
const behindRow = row.parent.children![parentIndex + 1];
|
|
|
+ const targetParent = getParent(tableData.value, behindRow.parent.id);
|
|
|
// 进行交换位置
|
|
|
- row.parent.children!.splice(parentIndex, 2, behindRow, row);
|
|
|
+ targetParent.children!.splice(parentIndex, 2, behindRow, row);
|
|
|
}
|
|
|
} else {
|
|
|
- const index = tableData.value.indexOf(row);
|
|
|
+ const index = tableData.value.findIndex((item) => item.id === row.id);
|
|
|
if (index < tableData.value.length - 1) {
|
|
|
tableData.value.splice(index, 2, tableData.value[index + 1], row);
|
|
|
}
|