|
|
@@ -4,8 +4,8 @@
|
|
|
:open="open"
|
|
|
:mask="false"
|
|
|
width="540px"
|
|
|
- @close="emit('update:open', false)"
|
|
|
- @ok="emit('update:open', false)"
|
|
|
+ @close="emits('update:open', false)"
|
|
|
+ @ok="saveGameConfig"
|
|
|
styles="position: fixed;top: 60px;right: 90px; pointer-events: none;"
|
|
|
>
|
|
|
<template #title>
|
|
|
@@ -76,7 +76,7 @@
|
|
|
<div v-else-if="currentLevel === 1">
|
|
|
<a-row class="config-game-list" :gutter="[8, 8]">
|
|
|
<a-col
|
|
|
- :span="12"
|
|
|
+ :span="10"
|
|
|
class="config-game-item"
|
|
|
v-for="(item, index) in cardJson.game_list[currentGameIndex].items"
|
|
|
:key="index"
|
|
|
@@ -89,12 +89,14 @@
|
|
|
<a-empty style="margin: 0 auto;" v-if="cardJson.game_list[currentGameIndex].items.length === 0" description="暂无游戏"> </a-empty>
|
|
|
</div>
|
|
|
|
|
|
- <!-- 三级内容:游戏步骤配置 v-else-if="currentLevel === 2" -->
|
|
|
- <div >
|
|
|
+ <!-- 三级内容:游戏步骤配置 -->
|
|
|
+ <div v-else-if="currentLevel === 2">
|
|
|
<div class="card-config-content">
|
|
|
- <!-- :item="cardJson.game_list[currentGameIndex].items[currentSubFolderIndex]" -->
|
|
|
<gameStage3
|
|
|
-
|
|
|
+ v-if="cardJson.game_list[currentGameIndex]?.items?.[currentSubFolderIndex]"
|
|
|
+ v-model="cardJson.game_list[currentGameIndex].items[currentSubFolderIndex].steps"
|
|
|
+ @update:modelValue="changedSteps"
|
|
|
+ @step-selected="emits('step-selected', $event)"
|
|
|
/>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -215,7 +217,7 @@
|
|
|
<script lang='ts' setup>
|
|
|
import { CardController } from '@/controller'
|
|
|
import { LeftOutlined, PlusOutlined, SmallDashOutlined, EditOutlined, DeleteOutlined, CheckCircleFilled, ExclamationCircleFilled } from '@ant-design/icons-vue'
|
|
|
-import { reactive, ref } from 'vue'
|
|
|
+import { reactive, ref, PropType, computed, watch } from 'vue'
|
|
|
import { message } from 'ant-design-vue'
|
|
|
import SelectAudioNew from './select-audio-new.vue'
|
|
|
import gameStage3 from './game-stage-3.vue'
|
|
|
@@ -224,38 +226,35 @@ const props = defineProps({
|
|
|
open: {
|
|
|
type: Boolean,
|
|
|
default: false
|
|
|
+ },
|
|
|
+ config: {
|
|
|
+ type: Object as PropType<API.CardJson21>,
|
|
|
+ default: () => ({})
|
|
|
}
|
|
|
})
|
|
|
-const emit = defineEmits(['update:open'])
|
|
|
+
|
|
|
+const emits = defineEmits(['update:open', 'step-selected', 'update:config'])
|
|
|
+
|
|
|
+// 卡片category为21的json
|
|
|
+const cardJson = computed({
|
|
|
+ get: () => props.config,
|
|
|
+ set: (value) => emits('update:config', value)
|
|
|
+})
|
|
|
|
|
|
// 一级folders的form
|
|
|
const game1FormJson = {
|
|
|
- rule: '7',
|
|
|
- mainSubject: { music_name: '102.mp3', is_break: 1 },
|
|
|
- ordered_multiple_err: { music_name: '102.mp3', is_break: 1 },
|
|
|
- has_click_single: { music_name: '102.mp3', is_break: 1 },
|
|
|
- still_have: { music_name: '102.mp3', is_break: 1 },
|
|
|
- has_click_group: { music_name: '102.mp3', is_break: 1 },
|
|
|
- wait_30s: { music_name: '102.mp3', is_break: 1 },
|
|
|
- wait_90s: { music_name: '102.mp3', is_break: 1 }
|
|
|
+ rule: '',
|
|
|
+ main_subject: { music_name: '', is_break: 1 },
|
|
|
+ ordered_multiple_err: { music_name: '', is_break: 1 },
|
|
|
+ has_click_single: { music_name: '', is_break: 1 },
|
|
|
+ still_have: { music_name: '', is_break: 1 },
|
|
|
+ has_click_group: { music_name: '', is_break: 1 },
|
|
|
+ wait_30s: { music_name: '', is_break: 1 },
|
|
|
+ wait_90s: { music_name: '', is_break: 1 }
|
|
|
}
|
|
|
|
|
|
// 当前层级:0表示顶级文件夹,1表示sub文件夹,2表示游戏配置
|
|
|
-const currentLevel = ref(2)
|
|
|
-
|
|
|
-// 点击路径的index
|
|
|
-const currentFolderIndex = reactive({
|
|
|
- folder: 0,
|
|
|
- subFolder: 0,
|
|
|
- step: 0
|
|
|
-})
|
|
|
-
|
|
|
-// 卡片category为21的json
|
|
|
-const cardJson = reactive<API.CardJson21>({
|
|
|
- game_list: []
|
|
|
-})
|
|
|
-
|
|
|
-const dropdownVisible = ref(false)
|
|
|
+const currentLevel = ref(0)
|
|
|
|
|
|
// 规则下拉选项
|
|
|
const ruleOptions = CardController.ruleList
|
|
|
@@ -287,8 +286,8 @@ const subItemForm = reactive({
|
|
|
},
|
|
|
ok_key: [],
|
|
|
err_key: [],
|
|
|
- ok_key_voice: [],
|
|
|
- err_key_voice: []
|
|
|
+ ok_key_voice: {},
|
|
|
+ err_key_voice: {}
|
|
|
})
|
|
|
|
|
|
// 当前选中的游戏索引
|
|
|
@@ -312,14 +311,14 @@ const getModalTitle = () => {
|
|
|
}
|
|
|
|
|
|
const createGameOne = () => {
|
|
|
- cardJson.game_list.push(JSON.parse(JSON.stringify(game1FormJson)))
|
|
|
+ cardJson.value.game_list.push(JSON.parse(JSON.stringify(game1FormJson)))
|
|
|
}
|
|
|
|
|
|
// 校验游戏配置是否完整
|
|
|
const validateGameConfig = (gameConfig: any) => {
|
|
|
const requiredFields = [
|
|
|
'rule',
|
|
|
- 'mainSubject.music_name',
|
|
|
+ 'main_subject.music_name',
|
|
|
'ordered_multiple_err.music_name',
|
|
|
'has_click_single.music_name',
|
|
|
'still_have.music_name',
|
|
|
@@ -351,7 +350,7 @@ const validateGameConfig = (gameConfig: any) => {
|
|
|
|
|
|
// 进入二级文件夹
|
|
|
const enterFolder = (index: number) => {
|
|
|
- const gameConfig = cardJson.game_list[index]
|
|
|
+ const gameConfig = cardJson.value.game_list[index]
|
|
|
const validation = validateGameConfig(gameConfig)
|
|
|
|
|
|
if (!validation.isValid) {
|
|
|
@@ -375,14 +374,18 @@ const enterFolder = (index: number) => {
|
|
|
}
|
|
|
|
|
|
// 验证通过,创建 items 数组(如果不存在)
|
|
|
- if (!cardJson.game_list[index].items) {
|
|
|
- cardJson.game_list[index].items = []
|
|
|
+ if (!cardJson.value.game_list[index].items) {
|
|
|
+ cardJson.value.game_list[index].items = []
|
|
|
}
|
|
|
|
|
|
currentGameIndex.value = index
|
|
|
currentLevel.value = 1
|
|
|
}
|
|
|
|
|
|
+const changedSteps = (steps: any) => {
|
|
|
+ console.log('changedSteps:', cardJson.value.game_list[currentGameIndex.value].items)
|
|
|
+}
|
|
|
+
|
|
|
const createSubItem = () => {
|
|
|
// 重置表单并打开弹窗
|
|
|
subItemForm.sub_subject.music_name = ''
|
|
|
@@ -393,8 +396,8 @@ const createSubItem = () => {
|
|
|
subItemForm.sub_subject.eb = ''
|
|
|
subItemForm.ok_key = []
|
|
|
subItemForm.err_key = []
|
|
|
- subItemForm.ok_key_voice = []
|
|
|
- subItemForm.err_key_voice = []
|
|
|
+ subItemForm.ok_key_voice = {}
|
|
|
+ subItemForm.err_key_voice = {}
|
|
|
|
|
|
subItemModalVisible.value = true
|
|
|
}
|
|
|
@@ -408,7 +411,7 @@ const handleSaveSubItem = () => {
|
|
|
}
|
|
|
|
|
|
const index = currentGameIndex.value
|
|
|
- const currentGame = cardJson.game_list[index]
|
|
|
+ const currentGame = cardJson.value.game_list[index]
|
|
|
if (!currentGame) {
|
|
|
message.error('未选择有效的游戏')
|
|
|
return
|
|
|
@@ -423,16 +426,16 @@ const handleSaveSubItem = () => {
|
|
|
const newItem = {
|
|
|
sub_subject: {
|
|
|
music_name: subItemForm.sub_subject.music_name,
|
|
|
- mb: '',
|
|
|
+ mb: 1,
|
|
|
ok: '',
|
|
|
- ob: '',
|
|
|
+ ob: 1,
|
|
|
err: '',
|
|
|
- eb: ''
|
|
|
+ eb: 1
|
|
|
},
|
|
|
ok_key: [],
|
|
|
err_key: [],
|
|
|
- ok_key_voice: [],
|
|
|
- err_key_voice: []
|
|
|
+ ok_key_voice: {},
|
|
|
+ err_key_voice: {}
|
|
|
}
|
|
|
|
|
|
// 追加到 items
|
|
|
@@ -446,9 +449,8 @@ const handleSaveSubItem = () => {
|
|
|
// 进入卡片配置
|
|
|
const enterCardConfig = (index: number) => {
|
|
|
currentSubFolderIndex.value = index
|
|
|
- const currentItem = cardJson.game_list[currentGameIndex.value]?.items?.[index]
|
|
|
+ const currentItem = cardJson.value.game_list[currentGameIndex.value]?.items?.[index]
|
|
|
if (currentItem) {
|
|
|
- // 初始化步骤数组(如果不存在)
|
|
|
if (!currentItem.steps) {
|
|
|
currentItem.steps = []
|
|
|
}
|
|
|
@@ -467,21 +469,21 @@ const goBack = () => {
|
|
|
const handleEdit = (index: number) => {
|
|
|
editingIndex.value = index
|
|
|
// 将当前游戏数据复制到编辑表单
|
|
|
- Object.assign(editForm, JSON.parse(JSON.stringify(cardJson.game_list[index])))
|
|
|
+ Object.assign(editForm, JSON.parse(JSON.stringify(cardJson.value.game_list[index])))
|
|
|
editModalVisible.value = true
|
|
|
}
|
|
|
|
|
|
// 处理删除游戏
|
|
|
const handleDelete = (index: number) => {
|
|
|
// 从游戏列表中删除指定索引的游戏
|
|
|
- cardJson.game_list.splice(index, 1)
|
|
|
+ cardJson.value.game_list.splice(index, 1)
|
|
|
}
|
|
|
|
|
|
// 保存编辑
|
|
|
const handleSaveEdit = () => {
|
|
|
if (editingIndex.value >= 0) {
|
|
|
// 将编辑表单的数据保存到游戏列表
|
|
|
- Object.assign(cardJson.game_list[editingIndex.value], JSON.parse(JSON.stringify(editForm)))
|
|
|
+ Object.assign(cardJson.value.game_list[editingIndex.value], JSON.parse(JSON.stringify(editForm)))
|
|
|
}
|
|
|
editModalVisible.value = false
|
|
|
editingIndex.value = -1
|
|
|
@@ -493,6 +495,21 @@ const handleCancelEdit = () => {
|
|
|
editingIndex.value = -1
|
|
|
}
|
|
|
|
|
|
+// 保存游戏配置
|
|
|
+const saveGameConfig = async () => {
|
|
|
+ console.log('保存游戏配置:', CardController.stepsToItems(cardJson.value))
|
|
|
+ const defaultJson = await CardController.getDefaultJson()
|
|
|
+ CardController.add({
|
|
|
+ header: {
|
|
|
+ card_type: 21,
|
|
|
+ ...cardJson.value.header
|
|
|
+ },
|
|
|
+ game_list: CardController.stepsToItems(cardJson.value).game_list
|
|
|
+ })
|
|
|
+ // 在这里可以添加保存逻辑,比如调用API保存cardJson
|
|
|
+ // emit('update:open', false)
|
|
|
+}
|
|
|
+
|
|
|
</script>
|
|
|
|
|
|
<style lang='less' scoped>
|