<template>
  <div>
    <el-form inline>
      <el-form-item label="分组选择应用">
        <el-cascader
          :value="malValue"
          :options="options"
          @change="handleChange"
          filterable
        ></el-cascader>
      </el-form-item>
    </el-form>
  </div>
</template>

<script>
import { menuSelectApps } from "@/api/report";
export default {
  // model绑定value和change事件，实现双向绑定
  model: {
    prop: "myValue",
    event: "changeValue",
  },
  props: {
    menuCode: {
      type: String,
      default: "game.Overview",
    },
    platformId: {
      type: Number,
      default: 5,
    },
  },
  data() {
    return {
      options: [],
      malValue: [],
    };
  },

  created() {
    this.APIMenuSelectApps(); // 获取应用
  },

  methods: {
    APIMenuSelectApps() {
      let params = {
        platformId: this.platformId,
        menuCode: this.menuCode,
        belongGroup: true,
      };
      menuSelectApps(params).then((res) => {
        this.options = res.result.data;
      });
    },

    // 值改变时，发出事件个改变的值，通过model注册这个事件，实现双向绑定
    handleChange(val) {
      this.$emit("changeValue", val);
    },
  },
};
</script>

<style>
</style>