123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467 |
- <template>
- <div class="home">
- <el-container>
- <el-header>
- <div class="banner">
- <div class="login_content">
- <div class="before_login" v-if="!loginStatus">
- 用户名:<el-input
- v-model="username"
- placeholder="请输入用户名"
- ></el-input>
- 密码:<el-input
- v-model="password"
- placeholder="请输入密码"
- show-password
- ></el-input>
- <el-button @click="loginFunc">登录</el-button>
- </div>
- <div class="after_login" v-if="loginStatus">
- {{ userInfo.username }}
- <el-button @click="logoutFunc">退出</el-button>
- </div>
- </div>
- </div>
- <div class="func">
- <div>
- <el-menu
- :default-active="showMenuIndex"
- class="el-menu-demo"
- mode="horizontal"
- @select="handleMenuSelect"
- >
- <el-menu-item
- v-for="(item, index) in funcArr"
- :key="index"
- :index="item.index"
- >{{ item.label }}</el-menu-item
- >
- </el-menu>
- </div>
- </div>
- </el-header>
- <el-container class="router_container">
- <el-main>
- <ComprehensiveDisplay
- v-if="showIndex == '1'"
- v-bind="{
- index: 1,
- }"
- ></ComprehensiveDisplay>
- <DataLayer
- v-if="showIndex == '2'"
- v-bind="{
- index: 2,
- }"
- ></DataLayer>
- <DataQualityInspection
- v-if="showIndex == '3'"
- v-bind="{
- index: 3,
- }"
- ></DataQualityInspection>
- <DataAccess
- v-if="showIndex == '4'"
- v-bind="{
- index: 4,
- }"
- ></DataAccess>
- <DataDisplay
- v-if="showIndex == '5'"
- v-bind="{
- index: 5,
- }"
- ></DataDisplay>
- <DataServices
- v-if="showIndex == '6'"
- v-bind="{
- index: 6,
- }"
- ></DataServices>
- <Utilities
- v-if="showIndex == '7'"
- v-bind="{
- index: 7,
- }"
- ></Utilities>
- <SecondaryDevelopment
- v-if="showIndex == '8'"
- v-bind="{
- index: 8,
- }"
- ></SecondaryDevelopment>
- <SystemManagement
- v-if="showIndex == '9'"
- v-bind="{
- index: 9,
- }"
- ></SystemManagement>
- </el-main>
- </el-container>
- </el-container>
- </div>
- </template>
- <script>
- import login from "@/utils/login";
- import general from "@/api/general";
- import icon from "@/api/icon";
- export default {
- name: "Home",
- data() {
- return {
- username: "",
- password: "",
- loginStatus: false,
- userInfo: null,
- requestCode: systemConfig.requestCode,
- permissionUnlogin: [
- 10,
- 20, 21, 22,
- 30, 31, 32,
- 40, 41, 42, 43, 44,
- 50, 51, 52,
- 60, 61, 62,63, 64,
- 70, 71, 72, 73, 74, 75,
- 80, 81, 82, 83,
- 90, 91, 92,
- ],
- funcArr: null,
- showMenuIndex: "1",
- showIndex: "1",
- };
- },
- components: {
- ComprehensiveDisplay: () => import("@/views/ComprehensiveDisplay.vue"),
- DataLayer: () => import("@/views/DataLayer.vue"),
- DataQualityInspection: () => import("@/views/DataQualityInspection.vue"),
- DataAccess: () => import("@/views/DataAccess.vue"),
- DataDisplay: () => import("@/views/DataDisplay.vue"),
- DataServices: () => import("@/views/DataServices.vue"),
- Utilities: () => import("@/views/Utilities.vue"),
- SecondaryDevelopment: () => import("@/views/SecondaryDevelopment.vue"),
- SystemManagement: () => import("@/views/SystemManagement.vue"),
- // 综合展示
- // ComprehensiveDisplay
- // 数据图层
- // DataLayer
- // 数据质检
- // DataQualityInspection
- // 数据接入
- // DataAccess
- // 数据展示
- // DataDisplay
- // 数据服务
- // DataServices
- // 实用工具
- // Utilities
- // 二次开发
- // SecondaryDevelopment
- // 系统管理
- // SystemManagement
- },
- beforeCreate() {
- window.loginFunc = this.loginFunc;
- window.checkRequestCode = this.checkRequestCode;
- window.getMenu = this.getMenu;
- window.getIcon = this.getIcon;
- },
- created() {
- if (this.$store.getters.getUserState) {
- this.userInfo = this.$store.getters.getUserInfo;
- this.loginStatus = true;
- this.permissionFiltering([
- 10, 20, 21, 30, 31, 32, 40, 41, 42, 43, 44, 50, 51, 52, 60, 61, 62, 63,
- 64, 70, 71, 72, 73, 74, 75, 80, 81, 82, 83, 90, 91, 92,
- ]);
- } else {
- this.permissionFilteringUnlogin();
- }
- this.getMenu();
- this.getIcon();
- },
- mounted() {
- this.funcArr = this.$store.getters.getMenuListTotal;
- },
- methods: {
- handleMenuSelect(index) {
- this.showIndex = index;
- },
- // 登录
- loginFunc() {
- let that = this;
- login(this.username, this.password)
- .then((result) => {
- that.loginStatus = true;
- that.userInfo = result.content;
- that.$store.commit("setUserInfo", result.content);
- that.$store.commit("setToken", result.message);
- that.$store.commit("setUserState", true);
- // 页面刷新
- location.reload();
- })
- .catch((err) => {
- that.$message({
- type: "error",
- message: err,
- });
- });
- },
- // 退出
- logoutFunc() {
- this.loginStatus = false;
- this.userInfo = null;
- this.$store.commit("setUserInfo", []);
- this.$store.commit("setToken", "");
- this.$store.commit("setUserState", false);
- // 页面刷新
- location.reload();
- },
- // 权限筛选
- permissionFiltering(permissionArr) {
- let list = JSON.parse(
- JSON.stringify(this.$store.getters.getMenuListTotal)
- );
- list = list.filter(function (item) {
- if (permissionArr.indexOf(item.permission) > -1) {
- let children = null;
- if (item.children) {
- children = item.children.filter(function (_item) {
- if (!_item.permission) {
- return true; // 未有权限字段,不做判断
- }
- if (permissionArr.indexOf(_item.permission) > -1) {
- return true;
- } else {
- return false;
- }
- });
- item.children = children;
- return true;
- } else {
- return true;
- }
- } else {
- return false;
- }
- });
- this.$store.commit("setMenuListTotal", list);
- },
- //
- permissionFilteringUnlogin() {
- this.permissionFiltering(this.permissionUnlogin);
- },
- // 访问接口反馈
- checkRequestCode(result) {
- let that = this;
- return new Promise((resolve, reject) => {
- if (result.code == 212) {
- let obj = that.getParams();
- let autologin1 = obj.autologin;
- let autologin2 = localStorage.getItem("autologin");
- if (
- autologin1 == 1 ||
- autologin2 != null ||
- autologin2 != undefined
- ) {
- that.loginFunc();
- } else {
- that.$store.commit("setToken", "");
- that.$store.commit("setUserState", false);
- }
- } else {
- let code = that.requestCode[result.code];
- if (code == 206 || code == 207 || code == 208) {
- this.$router.push({
- path: "/error",
- });
- } else {
- that.$message({
- type: "warning",
- message: that.requestCode[result.code],
- });
- }
- }
- });
- },
- // 获取url参数
- getQueryString(name) {
- var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
- var r = window.location.search.substr(1).match(reg);
- if (r != null) return unescape(r[2]);
- return null;
- },
- // 获取图层
- getMenu() {
- let that = this;
- general
- .getLayerList()
- .then(function (result) {
- if (result.code == 200) {
- that.$store.commit("setLayerList", result.content);
- } else {
- checkRequestCode(result);
- }
- })
- .catch((err) => {
- that.$message({
- type: "error",
- message: err,
- });
- });
- },
- // 获取icon
- getIcon() {
- let that = this;
- icon
- .getIcon()
- .then((result) => {
- if (result.code == 200) {
- that.$store.commit("setIconList", result.content);
- } else {
- result.message = "标注图片获取失败,请重试!";
- checkRequestCode(result);
- }
- })
- .catch((err) => {
- that.$message({
- type: "error",
- message: err,
- });
- });
- },
- },
- };
- </script>
- <style lang="less" scoped>
- .home {
- height: 100%;
- width: 100%;
- }
- .el-container {
- height: 100%;
- }
- .router_container {
- height: calc(100% - @header_height);
- }
- .el-header {
- padding: 0 0;
- height: @header_height !important;
- box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.12);
- z-index: 1;
- .banner {
- height: 200px;
- width: 100%;
- position: relative;
- background: url(~@/assets/images/banner.png);
- .login_content {
- position: absolute;
- top: 20px;
- right: 50px;
- font-size: 16px;
- color: #ffffff;
- .before_login {
- .el-input {
- width: 150px;
- height: 30px;
- line-height: 30px;
- margin-right: 10px;
- /deep/ .el-input__inner {
- height: 30px;
- line-height: 30px;
- background: #ffffff33;
- border: 0px;
- color: #ffffff;
- &::-webkit-input-placeholder {
- color: #ffffff;
- }
- &::-moz-placeholder {
- color: #ffffff;
- }
- &:-ms-input-placeholder {
- color: #ffffff;
- }
- &::-webkit-input-placeholder {
- color: #ffffff;
- }
- &::placeholder {
- color: #ffffff;
- }
- }
- /deep/ .el-input__clear {
- line-height: 30px;
- color: #e3e3e3;
- &:hover {
- color: #ffffff;
- }
- }
- }
- .el-button {
- height: 30px;
- width: 60px;
- padding: 0 10px;
- background: #ffcc42; //#ffcc42
- color: #ffffff;
- border: 0px;
- font-size: 16px;
- vertical-align: bottom;
- &:hover {
- background: #ffc21c;
- }
- }
- }
- .after_login {
- .el-button {
- height: 30px;
- width: 60px;
- padding: 0 10px;
- background: #ffcc42; //#ffcc42
- color: #ffffff;
- border: 0px;
- font-size: 16px;
- margin-left: 20px;
- &:hover {
- background: #ffc21c;
- }
- }
- }
- }
- }
- .func {
- height: 60px;
- background: #40a2ff;
- .el-menu {
- background: transparent;
- width: fit-content;
- margin: 0 auto;
- border-bottom: 0px;
- .el-menu-item {
- font-family: Source Han Sans CN VF;
- font-size: 20px;
- color: #ffffff;
- width: 180px;
- text-align: center;
- border-bottom-color: transparent;
- &.is-active {
- font-weight: bold;
- background: transparent;
- }
- &:hover {
- font-weight: bold;
- background: transparent;
- }
- }
- }
- }
- }
- .el-main {
- padding: 0 0;
- background: #f9f9f9;
- padding: 30px 200px;
- }
- </style>
|