关卡管理排序

V0.1
yujialong 1 year ago
parent 26d3172827
commit 29d34de052
  1. 4
      src/api/config.ts
  2. 13
      src/views/Home.vue
  3. 127
      src/views/config/level/Index.vue
  4. 2
      src/views/product/bank/Config.vue

@ -12,4 +12,6 @@ export const financialMarketSave = async (data: Record<string, any>): Promise<an
export const delPass = async (data: number[]): Promise<any> => (await axios.post('/nakadai/nakadai/customsPass/batchDeletion', data)).data; export const delPass = async (data: number[]): Promise<any> => (await axios.post('/nakadai/nakadai/customsPass/batchDeletion', data)).data;
export const listPass = async (data: Record<string, any>): Promise<any> => (await axios.post('/nakadai/nakadai/customsPass/checkpointList', data)).data; export const listPass = async (data: Record<string, any>): Promise<any> => (await axios.post('/nakadai/nakadai/customsPass/checkpointList', data)).data;
export const savePass = async (data: Record<string, any>): Promise<any> => (await axios.post('/nakadai/nakadai/customsPass/save', data)).data; export const savePass = async (data: Record<string, any>): Promise<any> => (await axios.post('/nakadai/nakadai/customsPass/save', data)).data;
export const updatePass = async (data: Record<string, any>[]): Promise<any> => (await axios.post(`/nakadai/nakadai/customsPass/update`), data).data; export const updatePass = async (data: Record<string, any>[]): Promise<any> => (await axios.post(`/nakadai/nakadai/customsPass/update`, data)).data;
export const checkPointListByStu = async (projectId: number, displayCollection?: number | string = ''): Promise<any> =>
(await axios.post(`/nakadai/nakadai/customsPass/checkPointListByStu?projectId=${projectId}&displayCollection=${displayCollection}`)).data;

@ -34,8 +34,8 @@
@click="selecLevel(item)"> @click="selecLevel(item)">
<span class="num">LV.{{ i + 1 }}</span> <span class="num">LV.{{ i + 1 }}</span>
<div class="texts"> <div class="texts">
<h6>{{ numToChinese(item.customsPassName.split(' ')[0].replace('关卡', '')) }}</h6> <h6>{{ numToChinese(i + 1) }}</h6>
<p class="des mul-ellipsis2">{{ item.customsPassName.split(' ')[1] }}</p> <p class="des mul-ellipsis2">{{ item.customsPassName }}</p>
<img v-if="item.collect" <img v-if="item.collect"
class="icon" class="icon"
src="@/assets/images/level/star2.png" src="@/assets/images/level/star2.png"
@ -66,9 +66,8 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref, onMounted } from 'vue'; import { ref, onMounted } from 'vue';
import { checkPointList } from '@/api/judgment';
import { cancelCollection, collect } from '@/api/bank'; import { cancelCollection, collect } from '@/api/bank';
import { listPass } from '@/api/config'; import { checkPointListByStu } from '@/api/config';
import Panel from '@/components/Panel/index.vue'; import Panel from '@/components/Panel/index.vue';
import { useRouter, useRoute } from 'vue-router'; import { useRouter, useRoute } from 'vue-router';
import { ElMessage } from 'element-plus'; import { ElMessage } from 'element-plus';
@ -86,9 +85,7 @@ const step = 150;
// //
const getLevel = async (only: any = '') => { const getLevel = async (only: any = '') => {
if (only) collected.value = !collected.value; if (only) collected.value = !collected.value;
const { data } = await listPass({ const { data } = await checkPointListByStu(+projectId, collected.value ? 1 : '');
platformId: 1,
});
levels.value = data; levels.value = data;
}; };
// //
@ -101,7 +98,7 @@ const collectItem = async (item: Record<string, any>) => {
await cancelCollection(item.favoriteId); await cancelCollection(item.favoriteId);
} else { } else {
await collect({ await collect({
checkPointId: item.id, checkPointId: item.checkpointId,
projectId, projectId,
}); });
} }

@ -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"
trigger="hover">
<template #reference>
<el-icon class="rotate-90 cursor-pointer" <el-icon class="rotate-90 cursor-pointer"
:size="16" :size="16"
color="#877c7c"> color="#877c7c">
<MoreFilled /> <MoreFilled />
</el-icon> </el-icon>
<template #dropdown>
<el-dropdown-menu>
<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('删除成功!');
}; };

@ -264,7 +264,7 @@
class="ml-5" class="ml-5"
v-model="form.loanContract" v-model="form.loanContract"
placeholder="请选择"> placeholder="请选择">
<el-option v-for="item in config[6]?.recordChildren[1]?.subject?.itemList[0]?.children" <el-option v-for="item in config[6]?.recordChildren[1]?.recordChildren"
:key="item.itemId" :key="item.itemId"
:label="item.options" :label="item.options"
:value="item.itemId" /> :value="item.itemId" />

Loading…
Cancel
Save