|
|
@ -18,7 +18,7 @@ |
|
|
|
alt="" |
|
|
|
alt="" |
|
|
|
class="icon" /> |
|
|
|
class="icon" /> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<el-popconfirm title="您确定删除吗?" |
|
|
|
<el-popconfirm :title="delTitle" |
|
|
|
@confirm.stop="delAll"> |
|
|
|
@confirm.stop="delAll"> |
|
|
|
<template #reference> |
|
|
|
<template #reference> |
|
|
|
<div class="add-btn mr-2"> |
|
|
|
<div class="add-btn mr-2"> |
|
|
@ -48,23 +48,31 @@ |
|
|
|
@selection-change="handleSelectionChange"> |
|
|
|
@selection-change="handleSelectionChange"> |
|
|
|
<el-table-column label="移动" |
|
|
|
<el-table-column label="移动" |
|
|
|
width="100"> |
|
|
|
width="100"> |
|
|
|
<template #default="{ row }"> |
|
|
|
<template #default="{ row, $index }"> |
|
|
|
<el-dropdown @command="command => move(command,row)"> |
|
|
|
<el-popover placement="right" |
|
|
|
<el-icon class="rotate-90 cursor-pointer" |
|
|
|
trigger="hover"> |
|
|
|
:size="16" |
|
|
|
<template #reference> |
|
|
|
color="#877c7c"> |
|
|
|
<el-icon class="rotate-90 cursor-pointer" |
|
|
|
<MoreFilled /> |
|
|
|
:size="16" |
|
|
|
</el-icon> |
|
|
|
color="#877c7c"> |
|
|
|
<template #dropdown> |
|
|
|
<MoreFilled /> |
|
|
|
<el-dropdown-menu> |
|
|
|
</el-icon> |
|
|
|
<el-dropdown-item command="up">上移</el-dropdown-item> |
|
|
|
|
|
|
|
<el-dropdown-item command="down">下移</el-dropdown-item> |
|
|
|
|
|
|
|
<el-dropdown-item command="top">置顶</el-dropdown-item> |
|
|
|
|
|
|
|
<el-dropdown-item command="bottom">置底</el-dropdown-item> |
|
|
|
|
|
|
|
</el-dropdown-menu> |
|
|
|
|
|
|
|
</template> |
|
|
|
</template> |
|
|
|
</el-dropdown> |
|
|
|
<div class="flex items-center mb-2"> |
|
|
|
|
|
|
|
<el-input class="w-[80px]" |
|
|
|
|
|
|
|
v-model.number="row.serial"></el-input> |
|
|
|
|
|
|
|
<el-icon class="ml-2 cursor-pointer" |
|
|
|
|
|
|
|
:size="16" |
|
|
|
|
|
|
|
color="#877c7c" |
|
|
|
|
|
|
|
@click.stop="submitSerial(row, $index, row.serial)"> |
|
|
|
|
|
|
|
<Check /> |
|
|
|
|
|
|
|
</el-icon> |
|
|
|
|
|
|
|
</div> |
|
|
|
|
|
|
|
<p class="my-2 cursor-pointer" |
|
|
|
|
|
|
|
@click="submitSerial(row, $index, 1)">置顶</p> |
|
|
|
|
|
|
|
<p class="cursor-pointer" |
|
|
|
|
|
|
|
@click="submitSerial(row, $index, list.length)">置底</p> |
|
|
|
|
|
|
|
</el-popover> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column type="selection" |
|
|
|
<el-table-column type="selection" |
|
|
@ -85,13 +93,20 @@ |
|
|
|
placeholder="请输入关卡名称" |
|
|
|
placeholder="请输入关卡名称" |
|
|
|
v-model="row.customsPassName"></el-input> |
|
|
|
v-model="row.customsPassName"></el-input> |
|
|
|
<span v-else>{{ row.customsPassName }}</span> |
|
|
|
<span v-else>{{ row.customsPassName }}</span> |
|
|
|
<el-icon class="ml-2 cursor-pointer" |
|
|
|
<el-icon class="mx-2 cursor-pointer" |
|
|
|
:size="16" |
|
|
|
:size="16" |
|
|
|
color="#877c7c" |
|
|
|
color="#877c7c" |
|
|
|
@click="edit(row)"> |
|
|
|
@click="edit(row)"> |
|
|
|
<Check v-if="row.editing" /> |
|
|
|
<Check v-if="row.editing" /> |
|
|
|
<Edit v-else /> |
|
|
|
<Edit v-else /> |
|
|
|
</el-icon> |
|
|
|
</el-icon> |
|
|
|
|
|
|
|
<el-icon v-if="row.editing" |
|
|
|
|
|
|
|
class="cursor-pointer" |
|
|
|
|
|
|
|
:size="16" |
|
|
|
|
|
|
|
color="#877c7c" |
|
|
|
|
|
|
|
@click="cancel(row)"> |
|
|
|
|
|
|
|
<Close /> |
|
|
|
|
|
|
|
</el-icon> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</template> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
</el-table-column> |
|
|
@ -107,15 +122,14 @@ |
|
|
|
<el-switch v-if="row.checkpointId" |
|
|
|
<el-switch v-if="row.checkpointId" |
|
|
|
v-model="row.isEnable" |
|
|
|
v-model="row.isEnable" |
|
|
|
:active-value="1" |
|
|
|
:active-value="1" |
|
|
|
:inactive-value="0" |
|
|
|
:inactive-value="0" /> |
|
|
|
@change="switchEnable(row)" /> |
|
|
|
|
|
|
|
</template> |
|
|
|
</template> |
|
|
|
</el-table-column> |
|
|
|
</el-table-column> |
|
|
|
<el-table-column label="操作" |
|
|
|
<el-table-column label="操作" |
|
|
|
width="140"> |
|
|
|
width="140"> |
|
|
|
<template #default="{ row }"> |
|
|
|
<template #default="{ row }"> |
|
|
|
<el-popconfirm v-if="row.checkpointId" |
|
|
|
<el-popconfirm v-if="row.checkpointId" |
|
|
|
title="您确定删除吗?" |
|
|
|
:title="delTitle" |
|
|
|
@confirm.stop="handleDelete([row.checkpointId])"> |
|
|
|
@confirm.stop="handleDelete([row.checkpointId])"> |
|
|
|
<template #reference> |
|
|
|
<template #reference> |
|
|
|
<el-button type="text" |
|
|
|
<el-button type="text" |
|
|
@ -128,7 +142,8 @@ |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<div class="filter flex justify-end mt-3"> |
|
|
|
<div class="filter flex justify-end mt-3"> |
|
|
|
<div class="add-btn" |
|
|
|
<div class="add-btn" |
|
|
|
@click="save"> |
|
|
|
@click="save" |
|
|
|
|
|
|
|
v-loading="saveLoading"> |
|
|
|
保存 |
|
|
|
保存 |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -138,7 +153,7 @@ |
|
|
|
<script setup lang="ts"> |
|
|
|
<script setup lang="ts"> |
|
|
|
import { computed, onMounted, ref, reactive, watch, nextTick } from 'vue'; |
|
|
|
import { computed, onMounted, ref, reactive, watch, nextTick } from 'vue'; |
|
|
|
import { ElMessage, ElTable } from 'element-plus'; |
|
|
|
import { ElMessage, ElTable } from 'element-plus'; |
|
|
|
import { Delete, Edit, Check, MoreFilled } from '@element-plus/icons-vue'; |
|
|
|
import { Delete, Edit, Check, MoreFilled, Close } from '@element-plus/icons-vue'; |
|
|
|
import { listPass, savePass, updatePass } from '@/api/config'; |
|
|
|
import { listPass, savePass, updatePass } from '@/api/config'; |
|
|
|
import Search from '@/components/Search.vue'; |
|
|
|
import Search from '@/components/Search.vue'; |
|
|
|
import { useRouter, useRoute } from 'vue-router'; |
|
|
|
import { useRouter, useRoute } from 'vue-router'; |
|
|
@ -150,6 +165,7 @@ const projectId = +Cookies.get('sand-projectId'); |
|
|
|
const levelId = +Cookies.get('sand-level'); |
|
|
|
const levelId = +Cookies.get('sand-level'); |
|
|
|
const height = window.innerHeight - 270; |
|
|
|
const height = window.innerHeight - 270; |
|
|
|
const tableRef = ref<InstanceType<typeof ElTable>>(); |
|
|
|
const tableRef = ref<InstanceType<typeof ElTable>>(); |
|
|
|
|
|
|
|
const delTitle: string = '删除关卡后,这个关卡的数据将被删除,确定删除吗?'; |
|
|
|
const params = reactive({ |
|
|
|
const params = reactive({ |
|
|
|
platformId: 3, |
|
|
|
platformId: 3, |
|
|
|
customsPassName: '', |
|
|
|
customsPassName: '', |
|
|
@ -168,12 +184,16 @@ const enables = ref<Array<any>>([ |
|
|
|
]); |
|
|
|
]); |
|
|
|
const list = ref<Array<any>>([]); |
|
|
|
const list = ref<Array<any>>([]); |
|
|
|
const loading = ref<boolean>(false); |
|
|
|
const loading = ref<boolean>(false); |
|
|
|
|
|
|
|
const saveLoading = ref<boolean>(false); |
|
|
|
const multipleSelection = ref<Record<string, any>[]>([]); |
|
|
|
const multipleSelection = ref<Record<string, any>[]>([]); |
|
|
|
// 列表 |
|
|
|
// 列表 |
|
|
|
const getList = async () => { |
|
|
|
const getList = async () => { |
|
|
|
loading.value = true; |
|
|
|
loading.value = true; |
|
|
|
try { |
|
|
|
try { |
|
|
|
const { data } = await listPass(params); |
|
|
|
const { data } = await listPass(params); |
|
|
|
|
|
|
|
data.forEach((e, i) => { |
|
|
|
|
|
|
|
e.serial = ''; |
|
|
|
|
|
|
|
}); |
|
|
|
list.value = data; |
|
|
|
list.value = data; |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
loading.value = false; |
|
|
|
loading.value = false; |
|
|
@ -186,15 +206,30 @@ onMounted(() => { |
|
|
|
watch([params, () => route.query], getList); |
|
|
|
watch([params, () => route.query], getList); |
|
|
|
|
|
|
|
|
|
|
|
// 保存 |
|
|
|
// 保存 |
|
|
|
const save = () => {}; |
|
|
|
const save = async () => { |
|
|
|
// 移动 |
|
|
|
if (saveLoading.value) return false; |
|
|
|
const move = async (command: string | number | object, row: Record<string, any>) => { |
|
|
|
saveLoading.value = true; |
|
|
|
const type = command === 'up' ? 1 : command === 'down' ? 2 : command === 'top' ? 3 : 4; |
|
|
|
const param = list.value.map((e, i) => { |
|
|
|
await updatePass({ |
|
|
|
e.serialNumber = i + 1; |
|
|
|
checkpointId: row.checkpointId, |
|
|
|
return { |
|
|
|
type, |
|
|
|
checkpointId: e.checkpointId, |
|
|
|
|
|
|
|
customsPassName: e.customsPassName, |
|
|
|
|
|
|
|
isEnable: e.isEnable, |
|
|
|
|
|
|
|
serialNumber: e.serialNumber, |
|
|
|
|
|
|
|
}; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
await updatePass(param); |
|
|
|
getList(); |
|
|
|
getList(); |
|
|
|
|
|
|
|
ElMessage.success('保存成功!'); |
|
|
|
|
|
|
|
saveLoading.value = false; |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
// 输入序号排序 |
|
|
|
|
|
|
|
const submitSerial = (row: Record<string, any>, oldIndex: number, newIndex: number) => { |
|
|
|
|
|
|
|
if (newIndex) { |
|
|
|
|
|
|
|
const temp = list.value.splice(oldIndex, 1); |
|
|
|
|
|
|
|
row.serialNumber = newIndex; |
|
|
|
|
|
|
|
list.value.splice(newIndex - 1, 0, temp[0]); |
|
|
|
|
|
|
|
} |
|
|
|
}; |
|
|
|
}; |
|
|
|
// 多选 |
|
|
|
// 多选 |
|
|
|
const handleSelectionChange = (val: Record<string, any>[]) => { |
|
|
|
const handleSelectionChange = (val: Record<string, any>[]) => { |
|
|
@ -202,15 +237,11 @@ const handleSelectionChange = (val: Record<string, any>[]) => { |
|
|
|
}; |
|
|
|
}; |
|
|
|
// 新增 |
|
|
|
// 新增 |
|
|
|
const toAdd = () => { |
|
|
|
const toAdd = () => { |
|
|
|
console.log(22, window.innerHeight); |
|
|
|
|
|
|
|
list.value.push({ |
|
|
|
list.value.push({ |
|
|
|
customsPassName: '', |
|
|
|
customsPassName: '', |
|
|
|
editing: true, |
|
|
|
editing: true, |
|
|
|
}); |
|
|
|
}); |
|
|
|
nextTick(() => { |
|
|
|
nextTick(() => { |
|
|
|
// tableRef.value.scrollTo({ |
|
|
|
|
|
|
|
// row: list.value.length, |
|
|
|
|
|
|
|
// }); |
|
|
|
|
|
|
|
document.querySelector('#tableWrap').scrollTo({ |
|
|
|
document.querySelector('#tableWrap').scrollTo({ |
|
|
|
top: document.querySelector('#tableWrap')?.scrollHeight + 200, |
|
|
|
top: document.querySelector('#tableWrap')?.scrollHeight + 200, |
|
|
|
behavior: 'smooth', |
|
|
|
behavior: 'smooth', |
|
|
@ -220,37 +251,25 @@ const toAdd = () => { |
|
|
|
|
|
|
|
|
|
|
|
// 编辑 |
|
|
|
// 编辑 |
|
|
|
const edit = async (row: Record<string, any>) => { |
|
|
|
const edit = async (row: Record<string, any>) => { |
|
|
|
if (row.editing) { |
|
|
|
if (!row.editing) { |
|
|
|
const param = { |
|
|
|
row.oldName = row.customsPassName; |
|
|
|
checkpointId: row.checkpointId || '', |
|
|
|
|
|
|
|
customsPassName: row.customsPassName, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
if (row.checkpointId) { |
|
|
|
|
|
|
|
await updatePass(param); |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
await savePass(param); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
getList(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
row.editing = !row.editing; |
|
|
|
row.editing = !row.editing; |
|
|
|
}; |
|
|
|
}; |
|
|
|
// 禁启用 |
|
|
|
// 取消 |
|
|
|
const switchEnable = async (row: Record<string, any>) => { |
|
|
|
const cancel = async (row: Record<string, any>) => { |
|
|
|
if (row.checkpointId) { |
|
|
|
row.customsPassName = row.oldName; |
|
|
|
await updatePass([ |
|
|
|
row.editing = !row.editing; |
|
|
|
{ |
|
|
|
|
|
|
|
checkpointId: row.checkpointId, |
|
|
|
|
|
|
|
isEnable: row.isEnable, |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
]); |
|
|
|
|
|
|
|
getList(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
// 删除 |
|
|
|
// 删除 |
|
|
|
const handleDelete = async (id: number[]) => { |
|
|
|
const handleDelete = async (id: number[]) => { |
|
|
|
id.map((e) => (e.isDel = 1)); |
|
|
|
const param = id.map((e) => { |
|
|
|
await updatePass(id); |
|
|
|
return { |
|
|
|
|
|
|
|
checkpointId: e, |
|
|
|
|
|
|
|
isDel: 1, |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
await updatePass(param); |
|
|
|
getList(); |
|
|
|
getList(); |
|
|
|
ElMessage.success('删除成功!'); |
|
|
|
ElMessage.success('删除成功!'); |
|
|
|
}; |
|
|
|
}; |
|
|
|