Bladeren bron

fix: 修复视频预览相关bug

mnisting 2 maanden geleden
bovenliggende
commit
173495daf7

+ 22 - 3
src/views/interactVideo/videoManage/index.vue

@@ -201,6 +201,7 @@ function handleDelete(row) {
 // 视频预览
 const videoViewOpen = ref(false);
 const videoDetail = ref({});
+const videoSource = ref([]);
 const graphData = ref({
   id: "0",
   type: "root-node",
@@ -227,6 +228,7 @@ function handleView(row) {
         return proxy.$modal.msgError("暂无可播放视频,可添加视频素材后预览");
       graphData.value = transfromReturnGraphdata(res.data.rootNode);
       videoDetail.value = graphData.value;
+      videoSource.value = treeToArray(graphData.value);
       if (!videoDetail.value.data.uri) {
         proxy.$modal.msgError("暂无可播放视频,可添加视频素材后预览");
         return;
@@ -238,9 +240,26 @@ function handleView(row) {
 
 // 点击选中选项
 const onClickOption = (option) => {
-  videoDetail.value = graphData.value.children.filter(
-    (i) => i.id == option.nodeId
-  )[0];
+  // 过滤出当前选中项的nodeId和视频资源的id相同的项
+  let videoData = videoSource.value.filter((i) => i.id == option.nodeId)[0];
+  // 如果筛选出的数据 节点类型时跳转节点的,需要特殊处理一下:筛选出视频资源中id和跳转jumpNodeId相同的数据
+  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;
 };
 
 function handleAdd() {

+ 22 - 3
src/views/interactVideo/videoManage/videoOperation.vue

@@ -92,6 +92,7 @@ function getInitData() {
     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);
     }
   });
@@ -146,6 +147,7 @@ function formSubmit() {
 // 视频预览
 const videoViewOpen = ref(false);
 const videoDetail = ref({});
+const videoSource = ref([]);
 
 function videoView() {
   videoDetail.value = graphData.value;
@@ -158,9 +160,26 @@ function videoView() {
 }
 // 点击选中选项
 const onClickOption = (option) => {
-  videoDetail.value = graphData.value.children.filter(
-    (i) => i.id == option.nodeId
-  )[0];
+  // 过滤出当前选中项的nodeId和视频资源的id相同的项
+  let videoData = videoSource.value.filter((i) => i.id == option.nodeId)[0];
+  // 如果筛选出的数据 节点类型时跳转节点的,需要特殊处理一下:筛选出视频资源中id和跳转jumpNodeId相同的数据
+  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);