|
|
@@ -2,7 +2,7 @@
|
|
|
* @Author: fxs bjnsfxs@163.com
|
|
|
* @Date: 2024-09-02 17:57:15
|
|
|
* @LastEditors: fxs bjnsfxs@163.com
|
|
|
- * @LastEditTime: 2024-09-12 18:01:11
|
|
|
+ * @LastEditTime: 2024-09-13 12:02:28
|
|
|
* @FilePath: \Game-Backstage-Management-System\src\views\AppManage\EventManageView.vue
|
|
|
* @Description:
|
|
|
*
|
|
|
@@ -10,13 +10,16 @@
|
|
|
<script setup lang="ts">
|
|
|
import HeaderCard from '@/components/dataAnalysis/HeaderCard.vue'
|
|
|
import { shouldListenToEvent } from '@/utils/table/table'
|
|
|
-import { onMounted, ref, reactive } from 'vue'
|
|
|
-import { ElMessage } from 'element-plus'
|
|
|
+import { onMounted, ref, reactive, computed } from 'vue'
|
|
|
+
|
|
|
+// import { ElMessage, ElNotification } from 'element-plus'
|
|
|
+
|
|
|
import FileUpload from '@/components/form/FileUpload.vue'
|
|
|
import axiosInstance from '@/utils/axios/axiosInstance'
|
|
|
import { useRequest } from '@/hooks/useRequest'
|
|
|
import { useCommonStore } from '@/stores/useCommon'
|
|
|
import { downLoadData } from '@/utils/table/table'
|
|
|
+
|
|
|
import { resetTimeToMidnight } from '@/utils/common'
|
|
|
import router from '@/router'
|
|
|
|
|
|
@@ -38,8 +41,8 @@ const uploadInfo = reactive({
|
|
|
dialogTitle: '上传事件信息'
|
|
|
})
|
|
|
|
|
|
-// 现在所有的选项列表
|
|
|
-// const nowOptionList: Array<any> = []
|
|
|
+// 现在的路由路径名称
|
|
|
+const nowRouteName = computed(() => router.currentRoute.value.name)
|
|
|
|
|
|
/**
|
|
|
* @description: 进入详情页,触发headercard的添加事件,增加一个面包屑导航
|
|
|
@@ -52,20 +55,33 @@ const headerAddPath = (info: any) => {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * @description: 提交所有新上传的事件及选项请求
|
|
|
+ * @description: 提交所有新上传的事件及选项请求
|
|
|
* @param {*} reqList 请求列表
|
|
|
+ * @param {*} msg 提示信息,用于展示上传之后返回的消息
|
|
|
* @return {*}
|
|
|
*/
|
|
|
-const submitUpload = async (reqList: Array<Promise<boolean>>) => {
|
|
|
+const submitUpload = async (reqList: Array<Promise<boolean>>, msg?: string) => {
|
|
|
await Promise.allSettled(reqList).then((res) => {
|
|
|
if (
|
|
|
res.every((item) => {
|
|
|
return item.status === 'fulfilled' && item.value === true
|
|
|
})
|
|
|
) {
|
|
|
- ElMessage.success('上传成功')
|
|
|
+ ElNotification({
|
|
|
+ type: 'success',
|
|
|
+ title: '上传完成',
|
|
|
+ message: `${msg}上传成功`,
|
|
|
+ position: 'top-left'
|
|
|
+ })
|
|
|
} else {
|
|
|
- ElMessage.error('部分上传失败,请检查参数')
|
|
|
+ ElNotification({
|
|
|
+ type: 'error',
|
|
|
+ title: '上传完成',
|
|
|
+ message: `${msg}部分上传失败,请检查参数`,
|
|
|
+ duration: 3000,
|
|
|
+ position: 'top-left'
|
|
|
+ })
|
|
|
+ // ElMessage.error()
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
@@ -142,21 +158,41 @@ const batReqOptionsData = async (
|
|
|
return finalResult
|
|
|
}
|
|
|
|
|
|
+type GetTableReturn<T> = T extends 'all'
|
|
|
+ ? { allEventTable: Array<any>; allOptionsInfo: any }
|
|
|
+ : T extends 'event'
|
|
|
+ ? { allEventTable: Array<any> }
|
|
|
+ : T extends 'option'
|
|
|
+ ? { allOptionsInfo: any }
|
|
|
+ : never
|
|
|
+
|
|
|
/**
|
|
|
* @description: 拿到事件数据和选项数据,首先需要拿到所有的事件列表,然后将他们的actionId抽出来形成一个列表,这个列表去作为optin的查询参数批量查询
|
|
|
* @return {*} 返回事件数据和选项数据
|
|
|
*/
|
|
|
-const getAllTable = async (): Promise<{ allEventTable: Array<any>; allOptionsInfo: any }> => {
|
|
|
- let allEventTable = await getTableData(AllApi.gameActionList, { gid: selectInfo.gid })
|
|
|
- let optionReqList = allEventTable.map((item) => {
|
|
|
- return { actionId: parseInt(item.id) }
|
|
|
- })
|
|
|
- let allOptionsInfo = await batReqOptionsData(
|
|
|
- AllApi.gameActionOptionList,
|
|
|
- optionReqList,
|
|
|
- allEventTable
|
|
|
- )
|
|
|
- return { allEventTable, allOptionsInfo }
|
|
|
+const getAllTable = async <T extends 'all' | 'event' | 'option' = 'all'>(
|
|
|
+ table?: T
|
|
|
+): Promise<GetTableReturn<T>> => {
|
|
|
+ let allEventTable: Array<any> = [],
|
|
|
+ allOptionsInfo: any = null
|
|
|
+ if (table === 'event') {
|
|
|
+ allEventTable = await getTableData(AllApi.gameActionList, { gid: selectInfo.gid })
|
|
|
+ return { allEventTable } as GetTableReturn<T>
|
|
|
+ }
|
|
|
+
|
|
|
+ if (table === 'option') {
|
|
|
+ let optionReqList = allEventTable.map((item) => {
|
|
|
+ return { actionId: parseInt(item.id) }
|
|
|
+ })
|
|
|
+ allOptionsInfo = await batReqOptionsData(
|
|
|
+ AllApi.gameActionOptionList,
|
|
|
+ optionReqList,
|
|
|
+ allEventTable
|
|
|
+ )
|
|
|
+ return { allOptionsInfo } as GetTableReturn<T>
|
|
|
+ }
|
|
|
+
|
|
|
+ return { allEventTable, allOptionsInfo } as GetTableReturn<T>
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -195,9 +231,10 @@ const startDownload = async () => {
|
|
|
const uploadSuccess = async (data: any) => {
|
|
|
let uploadEventTable = data.allEventTable
|
|
|
let uploadOptionsInfo = data.allOptionsInfo
|
|
|
-
|
|
|
+ let allEventTable: Array<any> = [],
|
|
|
+ allOptionsInfo: { [key: string]: any } = {}
|
|
|
// 上传的事件列表有值,则开始上传
|
|
|
- let { allEventTable, allOptionsInfo } = await getAllTable() // 获取所有事件列表和选项列表
|
|
|
+ ;({ allEventTable } = await getAllTable('event')) // 获取所有事件列表和选项列表
|
|
|
|
|
|
// 开始上传事件
|
|
|
let eventReqList: Array<Promise<boolean>> = []
|
|
|
@@ -223,7 +260,7 @@ const uploadSuccess = async (data: any) => {
|
|
|
})
|
|
|
eventReqList.push(eventReq) // 统一放入请求列表中
|
|
|
})
|
|
|
- await submitUpload(eventReqList) // 等待所有的事件请求完成
|
|
|
+ await submitUpload(eventReqList, '事件') // 等待所有的事件请求完成
|
|
|
}
|
|
|
;({ allEventTable, allOptionsInfo } = await getAllTable()) // 重新获取所有事件列表和选项列表
|
|
|
let optionsReqList: Array<Promise<boolean>> = []
|
|
|
@@ -267,8 +304,8 @@ const uploadSuccess = async (data: any) => {
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
- await submitUpload(optionsReqList)
|
|
|
- uploadRef.value?.closeUpload()
|
|
|
+ await submitUpload(optionsReqList, '选项') // 等待所有选项上传完成
|
|
|
+ uploadRef.value?.uploadCallback()
|
|
|
eventTableRef.value?.updateData()
|
|
|
}
|
|
|
|
|
|
@@ -286,7 +323,7 @@ onMounted(() => {})
|
|
|
></HeaderCard>
|
|
|
</div>
|
|
|
|
|
|
- <div class="handleEvent" v-if="router.currentRoute.value.name === 'EventTable'">
|
|
|
+ <div class="handleEvent" v-if="nowRouteName === 'EventTable'">
|
|
|
<div class="fileGroup">
|
|
|
<el-button class="fileBtn" color="#626aef" @click="startUpload">上传</el-button>
|
|
|
<el-button class="fileBtn" @click="startDownload">下载</el-button>
|