vue点击MenuItem回显图片到画布上

<template>
  <div class="box-outer">
    <div class="left">
      <Row>
        <Card style="height: 600px">
          <template #title>
            <Icon type="ios-film-outline"></Icon>
            结果列表
          </template>

          <Col span="4">
            <!-- <Tree :data="dataTree" @on-select-change="handleContextMenu" expand-node></Tree> -->
            <Menu theme="light" accordion @on-select="selectItem">
              <Submenu
                :name="index"
                v-for="(item, index) in boxs"
                :key="item.tag"
                ref="child"
              >
                <template slot="title">
                  <Icon type="ios-paper" /> {{ item.tag }}
                </template>
                <MenuItem
                  :name="item.tag + '---' + itemSub.path"
                  v-for="(itemSub, index) in item.imageList"
                  :key="itemSub.path"
                >
                  {{ itemSub.path }}
                </MenuItem>
              </Submenu>
            </Menu>
          </Col>
        </Card>
      </Row>
    </div>

    <div class="right">
      <div>
        <Card style="width: 70%; height: 600px">
          <template #title>
            <Icon type="ios-film-outline"></Icon>
            显示图片(右键图片,支持保存)
          </template>
          <img :src="base64data" alt="holy" height="500px" />
        </Card>
      </div>
    </div>
  </div>
</template>

<script>
import { showPythonResults, showPythonOnePic } from "@/api/data";

export default {
  data() {
    return {
      base64data: null,
      boxs: [
        // {
        //   imageList: [
        //     { path: "test_image1.jpg" },
        //     { path: "test_image111.jpg" },
        //   ],
        //   tag: "结果1",
        //   id: 1,
        // },
        // {
        //   imageList: [
        //     { path: "test_image33.jpg" },
        //     { path: "test_image333.jpg" },
        //   ],
        //   tag: "结果2",
        //   id: 2,
        // },
      ],
    };
  },
  created() {
    this.getPythonTaskInfo();
  },
  computed: {},
  methods: {
    selectItem(key) {
      console.log(10101, key, key.split("---")[0], key.split("---")[1]);
      let payload = {
        id: this.$route.query.rslt_uuid,
        username: this.$route.query.username,
        selected_path: key.split("---")[0],
        selected_file: key.split("---")[1],
      };
      console.log("abd", payload);
      showPythonOnePic(payload).then((res) => {
        console.log("aaaa```````````", res);
        const srrrc = window.URL.createObjectURL(res.data);
        this.base64data = srrrc;
      });
    },
    getPythonTaskInfo() {
      let taskUUID = this.$route.query.rslt_uuid;
      let taskUser = this.$route.query.username;
      console.log(10101, taskUUID, taskUser);
      let payload = {
        id: 29,
        uuid: taskUUID,
        username: taskUser,
      };
      showPythonResults(payload).then((res) => {
        let tempMenuOld = res.data.path_tree;
        console.log("hhhhh", res, tempMenuOld);
        let FirstLevelMenuList = Object.keys(tempMenuOld);
        console.log('FirstLevelMenuList',FirstLevelMenuList);
        for (let iii = 0, len = FirstLevelMenuList.length; iii < len; iii++) {
          let tag_1st = FirstLevelMenuList[iii];
          let imagelist_1st = [];
          if (tempMenuOld[FirstLevelMenuList[iii]].length > 0) {
            let pathArray = [];
            for (
              let ii = 0, len = tempMenuOld[FirstLevelMenuList[iii]].length;
              ii < len;
              ii++
            ) {
              let signelArray = {
                path: tempMenuOld[FirstLevelMenuList[iii]][ii],
              };
              console.log(333, signelArray);
              pathArray.push(signelArray);
            }
            imagelist_1st = pathArray;
          }
          let temp_menu = {
            id: iii,
            tag: tag_1st,
            imageList: imagelist_1st,
          };
          console.log('temp_menu',temp_menu);
          this.boxs.push(temp_menu);
        }

        // this.boxs = res.data.path_tree
      });
    },
  },
};
</script>
<style lang="less" scoped>
.box-outer {
  display: flex;
  padding: 0 0 0 0;
  width: 100%;
  height: 100%;

  .right {
    flex: 1;
  }
}
</style>

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值