123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200 |
- <template>
- <div class="app-container">
- <div style="display: flex">
- <el-button type="primary" @click="formSubmit">保存</el-button>
- <el-button type="primary" @click="addSource">管理素材</el-button>
- <el-button type="info" @click="videoView">视频预览</el-button>
- <el-button @click="returnList">返回</el-button>
- </div>
-
- <div class="border_box">
- <InteractiveVideoEditor
- ref="editorRef"
- :graphData="graphData"
- :videoSources="videoSources"
- :imageSources="imageSources"
- />
- </div>
-
- <el-dialog
- title="视频预览"
- v-model="videoViewOpen"
- width="1200"
- destroy-on-close
- >
- <XGVideoViewer
- :question="videoDetail.data.question"
- :options="videoDetail.data.optionsList"
- :videoUrl="videoDetail.data.uri"
- :autoplay="true"
- :autoplayMuted="false"
- :poster="videoDetail.data.image"
- @onClickOption="onClickOption"
- />
- </el-dialog>
-
- <AddSouce
- :open="materialOpen"
- :baseInfo="interactionVideoInfo"
- @close="formFieldsClose"
- />
- </div>
- </template>
- <script setup name="VideoOperation">
- import {
- interactionVideoUpdate,
- getInteractionVideoDetail,
- getMaterialInfoDetail,
- } from "@/api/interactVideo/videoManage";
- import {
- transformGraphdata,
- transfromReturnGraphdata,
- } from "@/hooks/transformGraphdata";
- import InteractiveVideoEditor from "@/components/InteractiveVideoEditor";
- import XGVideoViewer from "@/components/XGVideoViewer";
- import AddSouce from "./addSouce.vue";
- import { watchEffect } from "vue";
- const { proxy } = getCurrentInstance();
- const route = useRoute();
- const { interactionId } = route.query;
- const interactionVideoInfo = ref({});
- const videoSources = ref([]);
- const imageSources = ref([]);
- const editorRef = ref(null);
- const graphData = ref({
- id: "0",
- type: "root-node",
- preNodeId: null,
- children: [],
- data: {
- name: "默认节点",
- image: "",
- url: "",
- imageId: "",
- videoId: "",
- question: "",
- optionsList: [],
- },
- });
- function getInitData() {
-
- getInteractionVideoDetail(interactionId).then((res) => {
- if (res.code == 200) {
- interactionVideoInfo.value = res.data.interactionVideoInfo;
- graphData.value = transfromReturnGraphdata(res.data.rootNode);
- videoSource.value = treeToArray(graphData.value);
- console.log("graphData", graphData.value);
- }
- });
-
- getMaterialInfoDetail(interactionId).then((res) => {
-
- videoSources.value = res.data.materialLibraryVOList
- .filter((i) => i.materialType == 0)
- .map((i) => {
- return {
- id: i.materialId,
- name: i.materialName,
- url: i.accessory?.url,
- };
- });
- imageSources.value = res.data.materialLibraryVOList
- .filter((i) => i.materialType == 1)
- .map((i) => {
- return {
- id: i.materialId,
- name: i.materialName,
- url: i.accessory?.url,
- };
- });
- });
- }
- watchEffect(() => {
- getInitData();
- }, [interactionId]);
- function returnList() {
- proxy.$tab.closePage();
- }
- function formSubmit() {
-
- const rootNode = transformGraphdata(graphData.value);
- interactionVideoUpdate({
- interactionVideoInfo: interactionVideoInfo.value,
- rootNode,
- }).then((res) => {
- if (res.code == 200) {
- proxy.$modal.msgSuccess(res.msg);
- }
- });
- }
- const videoViewOpen = ref(false);
- const videoDetail = ref({});
- const videoSource = ref([]);
- function videoView() {
- videoDetail.value = graphData.value;
- console.log(videoDetail.value);
- if (!videoDetail.value.data.uri) {
- proxy.$modal.msgError("暂无可播放视频,可添加视频素材后预览");
- return;
- }
- videoViewOpen.value = true;
- }
- const onClickOption = (option) => {
-
- let videoData = videoSource.value.filter((i) => i.id == option.nodeId)[0];
-
- if (videoData.nodeType === "jump-node") {
- videoData = videoSource.value.filter(
- (i) => i.id == videoData.data.jumpNodeId
- )[0];
- }
- videoDetail.value = videoData;
- };
- const treeToArray = (tree, arr = []) => {
- arr.push(tree);
- if (tree.children) {
- for (let child of tree.children) {
- treeToArray(child, arr);
- }
- }
- return arr;
- };
- const materialOpen = ref(false);
- function addSource() {
- materialOpen.value = true;
- }
- function formFieldsClose() {
- materialOpen.value = false;
- getInitData();
- }
- </script>
- <style>
- .border_box {
- border: 1px solid #ccc;
- margin-top: 10px;
- }
- </style>
|