|
@@ -8,7 +8,11 @@
|
|
|
*
|
|
|
-->
|
|
|
<script setup lang="ts">
|
|
|
+import CustomDialog from '@/components/common/CustomDialog.vue'
|
|
|
+import type { DialogConfig } from '@/types/dialog.ts'
|
|
|
+import { FormFieldType } from '@/types/form.ts'
|
|
|
import type { ResponseInfo } from '@/types/res'
|
|
|
+import type { FormRules } from 'element-plus'
|
|
|
|
|
|
import { computed, reactive, ref } from 'vue'
|
|
|
import { useRequest } from '@/hooks/useRequest'
|
|
@@ -21,6 +25,8 @@ import router from '@/router'
|
|
|
import FileUpload from '@/components/form/FileUpload.vue'
|
|
|
import axiosInstance from '@/utils/axios/axiosInstance'
|
|
|
|
|
|
+type CustomDialogType = InstanceType<typeof CustomDialog>
|
|
|
+
|
|
|
interface uploadEvent {
|
|
|
id?: number // 更新需要传入id
|
|
|
gid: string
|
|
@@ -72,7 +78,7 @@ type GetTableReturn<T> = T extends 'all'
|
|
|
? { allOptionsInfo: { [key: string]: Array<DownLoadOption> } }
|
|
|
: never
|
|
|
|
|
|
-const { selectInfo } = useCommonStore()
|
|
|
+const { selectInfo, allGameInfo } = useCommonStore()
|
|
|
|
|
|
const { AllApi } = useRequest()
|
|
|
|
|
@@ -93,6 +99,78 @@ const uploadInfo = reactive({
|
|
|
// 现在的路由路径名称
|
|
|
const nowRouteName = computed(() => router.currentRoute.value.name)
|
|
|
|
|
|
+// 对话框表单规则字段
|
|
|
+const dialogRuleForm = reactive({
|
|
|
+ gid: '',
|
|
|
+ newGid: ''
|
|
|
+})
|
|
|
+
|
|
|
+/**
|
|
|
+ * 验证新旧游戏不能相同
|
|
|
+ * @param _rule 规则
|
|
|
+ * @param value 值
|
|
|
+ * @param callback 回调
|
|
|
+ */
|
|
|
+const checkNewGid = (_rule: any, value: any, callback: any) => {
|
|
|
+ if (value === '') {
|
|
|
+ callback(new Error('目标游戏必选'))
|
|
|
+ } else if (value === copyConfigDialogRef.value?.getFormData().gid) {
|
|
|
+ callback(new Error('目标游戏不能与原游戏相同'))
|
|
|
+ } else {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+// 对话表单规则
|
|
|
+const dialogRules = reactive<FormRules<typeof dialogRuleForm>>({
|
|
|
+ gid: [{ required: true, message: '原游戏必选', trigger: 'blur' }],
|
|
|
+ newGid: [
|
|
|
+ { required: true, message: '目标游戏必选', trigger: 'blur' },
|
|
|
+ { validator: checkNewGid, trigger: 'blur' }
|
|
|
+ ]
|
|
|
+})
|
|
|
+
|
|
|
+const copyConfigDialogRef = ref<CustomDialogType>()
|
|
|
+
|
|
|
+const gameOptions = allGameInfo.map((item) => {
|
|
|
+ return {
|
|
|
+ name: item.gid,
|
|
|
+ value: item.gid,
|
|
|
+ label: item.gameName
|
|
|
+ }
|
|
|
+})
|
|
|
+
|
|
|
+const configCopyInfo = ref<DialogConfig>({
|
|
|
+ title: '复制事件',
|
|
|
+ rules: dialogRules,
|
|
|
+ reqConfig: {
|
|
|
+ url: AllApi.copyActionConfig,
|
|
|
+ otherOptions: {}
|
|
|
+ },
|
|
|
+ fieldsInfo: [
|
|
|
+ {
|
|
|
+ name: 'gid',
|
|
|
+ cnName: '原游戏',
|
|
|
+ type: FormFieldType.SELECT,
|
|
|
+ defaultValue: selectInfo.gid,
|
|
|
+ otherOptions: {
|
|
|
+ options: gameOptions,
|
|
|
+ searchSelected: true
|
|
|
+ }
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'newGid',
|
|
|
+ cnName: '目标游戏',
|
|
|
+ type: FormFieldType.SELECT,
|
|
|
+
|
|
|
+ otherOptions: {
|
|
|
+ options: gameOptions,
|
|
|
+ searchSelected: true
|
|
|
+ }
|
|
|
+ }
|
|
|
+ ]
|
|
|
+})
|
|
|
+
|
|
|
/**
|
|
|
* 进入详情页,触发headerCard的添加事件,增加一个面包屑导航
|
|
|
* @param {*} info 传入的信息
|
|
@@ -441,6 +519,28 @@ const uploadSuccess = async (data: {
|
|
|
uploadRef.value?.uploadCallback()
|
|
|
eventTableRef.value?.updateData()
|
|
|
}
|
|
|
+
|
|
|
+const handleCopyConfig = () => {
|
|
|
+ copyConfigDialogRef.value?.addForm()
|
|
|
+}
|
|
|
+
|
|
|
+const defaultEventDialogVisible = ref(false)
|
|
|
+
|
|
|
+const events = [
|
|
|
+ { id: '1', name: '登录事件', enabled: true },
|
|
|
+ { id: '2', name: '注册事件', enabled: false }
|
|
|
+]
|
|
|
+
|
|
|
+const submitEventInfo = () => {
|
|
|
+ console.log(events.filter((item) => item.enabled))
|
|
|
+ const hasEmpty = events
|
|
|
+ .filter((item) => item.enabled)
|
|
|
+ .some((item) => item.id === '' || item.name === '')
|
|
|
+ if (hasEmpty) {
|
|
|
+ ElMessage.warning('请为所有启用事件填写完整信息')
|
|
|
+ return
|
|
|
+ }
|
|
|
+}
|
|
|
</script>
|
|
|
|
|
|
<template>
|
|
@@ -456,6 +556,11 @@ const uploadSuccess = async (data: {
|
|
|
|
|
|
<div class="handleEvent" v-if="nowRouteName === 'EventTable'">
|
|
|
<div class="fileGroup">
|
|
|
+ <el-button class="fileBtn" @click="handleCopyConfig">复制</el-button>
|
|
|
+ <!-- TODO 完善-->
|
|
|
+ <el-button class="fileBtn" @click="defaultEventDialogVisible = true" v-if="false"
|
|
|
+ >导入默认配置
|
|
|
+ </el-button>
|
|
|
<el-button class="fileBtn" color="#626aef" @click="startUpload">上传</el-button>
|
|
|
<el-button class="fileBtn" @click="throttleStartDownload">下载</el-button>
|
|
|
</div>
|
|
@@ -485,6 +590,42 @@ const uploadSuccess = async (data: {
|
|
|
:title="uploadInfo.dialogTitle"
|
|
|
></FileUpload>
|
|
|
</div>
|
|
|
+ <div>
|
|
|
+ <CustomDialog ref="copyConfigDialogRef" :config="configCopyInfo"></CustomDialog>
|
|
|
+ </div>
|
|
|
+ <div>
|
|
|
+ <el-dialog v-model="defaultEventDialogVisible" title="事件配置">
|
|
|
+ <el-table :data="events" style="width: 100%" table-layout="auto">
|
|
|
+ <!-- 是否启用列 -->
|
|
|
+ <el-table-column prop="enabled" label="是否启用" align="center">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <el-checkbox v-model="row.enabled" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
+ <!-- 事件ID列 -->
|
|
|
+ <el-table-column align="center" prop="id" label="事件ID">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <el-input v-model="row.id" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+
|
|
|
+ <!-- 事件名称列 -->
|
|
|
+ <el-table-column align="center" prop="name" label="事件名称">
|
|
|
+ <template #default="{ row }">
|
|
|
+ <el-input v-model="row.name" placeholder="事件名称" />
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
+ </el-table>
|
|
|
+
|
|
|
+ <template #footer>
|
|
|
+ <el-button type="primary" @click="submitEventInfo" style="margin-right: 10px"
|
|
|
+ >保存
|
|
|
+ </el-button>
|
|
|
+ <el-button @click="defaultEventDialogVisible = false">取消</el-button>
|
|
|
+ </template>
|
|
|
+ </el-dialog>
|
|
|
+ </div>
|
|
|
</div>
|
|
|
</template>
|
|
|
|