08335 / hivui-platform-template
hivui平台项目模板
Newer
Older
hivui-platform-template / project / hivuiMain / views / test / index.vue
caibinghong on 4 Jun 2021 add
<template>
  <div>
    <input type="button" value="取菜单" @click="getMenus" />
    <input type="button" value="取左侧菜单" @click="getQuickNav" />
    <input type="button" value="取门户预选功能" @click="getPortalMenus" />
    <input type="button" value="取已配的门户" @click="getPortal" />
    <input type="button" value="取系统门户" @click="getSysPortal" />
    <input type="button" value="取权限" @click="getPermissions" />
    

    <input type="button" value="取最近使用" @click="getLeastRecentlyUsed" />
    <!-- <input type="button" value="保存门户" @click="savePortal" /> -->
    <input type="button" value="添加门户" @click="addPortal" />
    <input type="button" value="修改门户" @click="updatePortal" />
    
    
    <textarea style="width:100%;height:600px">{{data}}</textarea>
  </div>
</template>
<script>
import { fetchColumns, fetchList, getPortal,getSysPortal, savePortal,addPortal,updatePortal } from "@main/api/portal";
import { getMenus, getQuickNav, getPortalMenus ,getLeastRecentlyUsed,getPermissions} from "@main/api/menu";
export default {
  data() {
    return {
      data: null
    };
  },
  mounted() {
    this.getPortalList();
  },
  methods: {
    //取顶部菜单
    getMenus() {
      getMenus().then(res => {
        this.data = JSON.stringify(res.data.dataPack.rows);
      });
    },
    //取左侧快速
    getQuickNav() {
      getQuickNav().then(res => {
        this.data = JSON.stringify(res.data.dataPack.rows);
      });
    },
    //取权限
    getPermissions() {
      getPermissions('admin').then(res => {
        this.data = JSON.stringify(res.data.dataPack.rows);
      });
    },
    
    //创建门户功能选择
    getPortalMenus() {
      getPortalMenus().then(res => {
        this.data = JSON.stringify(res.data.dataPack.rows);
      });
    },
    //取已配好的门户
    getPortal() {
      getPortal().then(res => {
        this.data = JSON.stringify(res.data.dataPack.rows);
      });
    },
    //取系统门户
    getSysPortal() {
      getSysPortal().then(res => {
        this.data = JSON.stringify(res.data.dataPack.rows);
      });
    },
    //取最近使用
    getLeastRecentlyUsed() {
      getLeastRecentlyUsed('admin').then(res => {
        this.data = JSON.stringify(res.data.dataPack.rows);
      });
    },
    
    addPortal() {
      let insertPack = {};
      insertPack = {
        FID: new Date().valueOf(),
        package: [{}]
      };
      addPortal(insertPack).then(res => {
        this.data = JSON.stringify(res.data);
      });
    },
    updatePortal() {
      let updatePack = {};
      updatePack = {
        package: [{ a: 1 }]
      };
      let oldPack = {
        FID: "1571726431976"
      };
      updatePortal(oldPack, updatePack).then(res => {
        this.data = JSON.stringify(res.data);
      });
    },
    //保存门户
    savePortal() {
      let insertPack = []; //添加包
      let updatePack = []; //修改包
      let removePack = []; //删除包
      insertPack.push({
        FID: new Date().valueOf(),
        FPID: "-1",
        NAME: "行",
        TYPE: "row",
        TRANSPARENT: false,
        URL: "功能url"
      });
      savePortal(insertPack, updatePack, removePack).then(res => {
        this.data = JSON.stringify(res.data.dataPack.rows);
      });
    },
    getPortalList() {
      fetchList().then(res => {});
    }
  }
};
</script>