11<script setup lang="ts">
22import {cloneDeep } from " lodash-es" ;
3- import {ref , watch } from " vue" ;
3+ import {nextTick , ref , watch } from " vue" ;
44import {t } from " ../../lang" ;
55import {Dialog } from " ../../lib/dialog" ;
66import SpeakerSelector from " ./SpeakerSelector.vue" ;
7+ import SoundPromptSelector from " ../../pages/Sound/components/SoundPromptSelector.vue" ;
78
89type FieldBasicType = {
910 name: string ;
1011 title: string ;
1112 icon: string ;
12- type: " select" | " input" | " inputNumber" | " switch" | " slider" | " speaker" ;
13+ type: " select"
14+ | " input"
15+ | " inputNumber"
16+ | " switch"
17+ | " slider"
18+ | " speaker" ;
1319 defaultValue: any ;
1420 placeholder: string ;
1521 required: boolean ;
@@ -42,10 +48,10 @@ watch(
4248 value => {
4349 formData .value = value ?.map (item => {
4450 const itemClone = cloneDeep (item );
45- if (itemClone .type === " speaker" ) {
46- itemClone [" speakerParam" ] = [];
47- itemClone [" speakerParamValue" ] = {};
48- }
51+ // if (itemClone.type === "speaker") {
52+ // itemClone["speakerParam"] = [];
53+ // itemClone["speakerParamValue"] = {};
54+ // }
4955 let value = itemClone .defaultValue ;
5056 if (item .opt ) {
5157 if (item .opt .includes (' randomValue' )) {
@@ -70,16 +76,21 @@ watch(
7076 deep: true ,
7177 }
7278);
79+ watch (() => formData .value , () => {
80+ nextTick (() => {
81+ emit (' change' , getValue ());
82+ })
83+ }, {immediate: false , deep: true });
7384
7485const getValue = () => {
7586 const result = {};
7687 formData .value .forEach (item => {
7788 result [item .name ] = item .value ;
7889 result [' _' + item .name ] = item .title ;
7990 if (item .type === " speaker" ) {
80- for (const k in item [" speakerParamValue" ]) {
81- result [k ] = item [" speakerParamValue" ][k ];
82- }
91+ // for (const k in item["speakerParamValue"]) {
92+ // result[k] = item["speakerParamValue"][k];
93+ // }
8394 result [` __${item .name } ` ] = item [" speaker" ]?.[" title" ] || item .value ;
8495 }
8596 });
@@ -104,24 +115,26 @@ const validate = () => {
104115 return true ;
105116};
106117
107- const onSpeakerDataUpdate = (name , data ) => {
108- const {param, speaker} = data ;
109- const item = formData .value .find (item => item .name === name );
110- if (item ) {
111- item [" speaker" ] = speaker ;
112- item [" speakerParam" ] = param ;
113- const value = {};
114- param .forEach (paramItem => {
115- value [paramItem .name ] = null ;
116- if (! paramItem .type || paramItem .type === " select" ) {
117- if (paramItem .option && paramItem .option .length > 0 ) {
118- value [paramItem .name ] = paramItem .option [0 ].value ;
119- }
120- }
121- });
122- item [" speakerParamValue" ] = value ;
123- }
124- };
118+ const emit = defineEmits ([' change' ]);
119+
120+ // const onSpeakerDataUpdate = (name, data) => {
121+ // const {param, speaker} = data;
122+ // const item = formData.value.find(item => item.name === name);
123+ // if (item) {
124+ // item["speaker"] = speaker;
125+ // item["speakerParam"] = param;
126+ // const value = {};
127+ // param.forEach(paramItem => {
128+ // value[paramItem.name] = null;
129+ // if (!paramItem.type || paramItem.type === "select") {
130+ // if (paramItem.option && paramItem.option.length > 0) {
131+ // value[paramItem.name] = paramItem.option[0].value;
132+ // }
133+ // }
134+ // });
135+ // item["speakerParamValue"] = value;
136+ // }
137+ // };
125138
126139defineExpose ({
127140 getValue ,
@@ -183,10 +196,15 @@ defineExpose({
183196 <a-slider v-model =" item.value" :marks =" item.sliderMarks" show-tooltip :min =" item.min" :max =" item.max"
184197 :disabled =" props.disabled" :step =" item.step" />
185198 </div >
186- <div v-else-if =" item.type === 'speaker'" class =" w-48 mr-3" >
199+ <div v-else-if =" item.type === 'speaker'" class =" mr-3" >
187200 <SpeakerSelector v-model =" item.value" :speakers =" item['speakers']" :disabled =" props.disabled"
188- @on-data-update =" onSpeakerDataUpdate(item.name, $event)" />
201+ />
202+ <!-- @on-data-update="onSpeakerDataUpdate(item.name, $event)" -->
203+ </div >
204+ <div v-else-if =" item.type === 'soundPromptId'" >
205+ <SoundPromptSelector v-model =" item.value" :disabled =" props.disabled" />
189206 </div >
207+ <!--
190208 <div v-for="speakerParam in item['speakerParam']">
191209 <div v-if="!speakerParam.type || speakerParam.type === 'select'" class="mr-3">
192210 <a-select size="small" :disabled="props.disabled"
@@ -197,6 +215,7 @@ defineExpose({
197215 </a-select>
198216 </div>
199217 </div>
218+ -->
200219 </div >
201220</template >
202221
0 commit comments