Home.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467
  1. <template>
  2. <div class="home">
  3. <el-container>
  4. <el-header>
  5. <div class="banner">
  6. <div class="login_content">
  7. <div class="before_login" v-if="!loginStatus">
  8. 用户名:<el-input
  9. v-model="username"
  10. placeholder="请输入用户名"
  11. ></el-input>
  12. 密码:<el-input
  13. v-model="password"
  14. placeholder="请输入密码"
  15. show-password
  16. ></el-input>
  17. <el-button @click="loginFunc">登录</el-button>
  18. </div>
  19. <div class="after_login" v-if="loginStatus">
  20. {{ userInfo.username }}
  21. <el-button @click="logoutFunc">退出</el-button>
  22. </div>
  23. </div>
  24. </div>
  25. <div class="func">
  26. <div>
  27. <el-menu
  28. :default-active="showMenuIndex"
  29. class="el-menu-demo"
  30. mode="horizontal"
  31. @select="handleMenuSelect"
  32. >
  33. <el-menu-item
  34. v-for="(item, index) in funcArr"
  35. :key="index"
  36. :index="item.index"
  37. >{{ item.label }}</el-menu-item
  38. >
  39. </el-menu>
  40. </div>
  41. </div>
  42. </el-header>
  43. <el-container class="router_container">
  44. <el-main>
  45. <ComprehensiveDisplay
  46. v-if="showIndex == '1'"
  47. v-bind="{
  48. index: 1,
  49. }"
  50. ></ComprehensiveDisplay>
  51. <DataLayer
  52. v-if="showIndex == '2'"
  53. v-bind="{
  54. index: 2,
  55. }"
  56. ></DataLayer>
  57. <DataQualityInspection
  58. v-if="showIndex == '3'"
  59. v-bind="{
  60. index: 3,
  61. }"
  62. ></DataQualityInspection>
  63. <DataAccess
  64. v-if="showIndex == '4'"
  65. v-bind="{
  66. index: 4,
  67. }"
  68. ></DataAccess>
  69. <DataDisplay
  70. v-if="showIndex == '5'"
  71. v-bind="{
  72. index: 5,
  73. }"
  74. ></DataDisplay>
  75. <DataServices
  76. v-if="showIndex == '6'"
  77. v-bind="{
  78. index: 6,
  79. }"
  80. ></DataServices>
  81. <Utilities
  82. v-if="showIndex == '7'"
  83. v-bind="{
  84. index: 7,
  85. }"
  86. ></Utilities>
  87. <SecondaryDevelopment
  88. v-if="showIndex == '8'"
  89. v-bind="{
  90. index: 8,
  91. }"
  92. ></SecondaryDevelopment>
  93. <SystemManagement
  94. v-if="showIndex == '9'"
  95. v-bind="{
  96. index: 9,
  97. }"
  98. ></SystemManagement>
  99. </el-main>
  100. </el-container>
  101. </el-container>
  102. </div>
  103. </template>
  104. <script>
  105. import login from "@/utils/login";
  106. import general from "@/api/general";
  107. import icon from "@/api/icon";
  108. export default {
  109. name: "Home",
  110. data() {
  111. return {
  112. username: "",
  113. password: "",
  114. loginStatus: false,
  115. userInfo: null,
  116. requestCode: systemConfig.requestCode,
  117. permissionUnlogin: [
  118. 10,
  119. 20, 21, 22,
  120. 30, 31, 32,
  121. 40, 41, 42, 43, 44,
  122. 50, 51, 52,
  123. 60, 61, 62,63, 64,
  124. 70, 71, 72, 73, 74, 75,
  125. 80, 81, 82, 83,
  126. 90, 91, 92,
  127. ],
  128. funcArr: null,
  129. showMenuIndex: "1",
  130. showIndex: "1",
  131. };
  132. },
  133. components: {
  134. ComprehensiveDisplay: () => import("@/views/ComprehensiveDisplay.vue"),
  135. DataLayer: () => import("@/views/DataLayer.vue"),
  136. DataQualityInspection: () => import("@/views/DataQualityInspection.vue"),
  137. DataAccess: () => import("@/views/DataAccess.vue"),
  138. DataDisplay: () => import("@/views/DataDisplay.vue"),
  139. DataServices: () => import("@/views/DataServices.vue"),
  140. Utilities: () => import("@/views/Utilities.vue"),
  141. SecondaryDevelopment: () => import("@/views/SecondaryDevelopment.vue"),
  142. SystemManagement: () => import("@/views/SystemManagement.vue"),
  143. // 综合展示
  144. // ComprehensiveDisplay
  145. // 数据图层
  146. // DataLayer
  147. // 数据质检
  148. // DataQualityInspection
  149. // 数据接入
  150. // DataAccess
  151. // 数据展示
  152. // DataDisplay
  153. // 数据服务
  154. // DataServices
  155. // 实用工具
  156. // Utilities
  157. // 二次开发
  158. // SecondaryDevelopment
  159. // 系统管理
  160. // SystemManagement
  161. },
  162. beforeCreate() {
  163. window.loginFunc = this.loginFunc;
  164. window.checkRequestCode = this.checkRequestCode;
  165. window.getMenu = this.getMenu;
  166. window.getIcon = this.getIcon;
  167. },
  168. created() {
  169. if (this.$store.getters.getUserState) {
  170. this.userInfo = this.$store.getters.getUserInfo;
  171. this.loginStatus = true;
  172. this.permissionFiltering([
  173. 10, 20, 21, 30, 31, 32, 40, 41, 42, 43, 44, 50, 51, 52, 60, 61, 62, 63,
  174. 64, 70, 71, 72, 73, 74, 75, 80, 81, 82, 83, 90, 91, 92,
  175. ]);
  176. } else {
  177. this.permissionFilteringUnlogin();
  178. }
  179. this.getMenu();
  180. this.getIcon();
  181. },
  182. mounted() {
  183. this.funcArr = this.$store.getters.getMenuListTotal;
  184. },
  185. methods: {
  186. handleMenuSelect(index) {
  187. this.showIndex = index;
  188. },
  189. // 登录
  190. loginFunc() {
  191. let that = this;
  192. login(this.username, this.password)
  193. .then((result) => {
  194. that.loginStatus = true;
  195. that.userInfo = result.content;
  196. that.$store.commit("setUserInfo", result.content);
  197. that.$store.commit("setToken", result.message);
  198. that.$store.commit("setUserState", true);
  199. // 页面刷新
  200. location.reload();
  201. })
  202. .catch((err) => {
  203. that.$message({
  204. type: "error",
  205. message: err,
  206. });
  207. });
  208. },
  209. // 退出
  210. logoutFunc() {
  211. this.loginStatus = false;
  212. this.userInfo = null;
  213. this.$store.commit("setUserInfo", []);
  214. this.$store.commit("setToken", "");
  215. this.$store.commit("setUserState", false);
  216. // 页面刷新
  217. location.reload();
  218. },
  219. // 权限筛选
  220. permissionFiltering(permissionArr) {
  221. let list = JSON.parse(
  222. JSON.stringify(this.$store.getters.getMenuListTotal)
  223. );
  224. list = list.filter(function (item) {
  225. if (permissionArr.indexOf(item.permission) > -1) {
  226. let children = null;
  227. if (item.children) {
  228. children = item.children.filter(function (_item) {
  229. if (!_item.permission) {
  230. return true; // 未有权限字段,不做判断
  231. }
  232. if (permissionArr.indexOf(_item.permission) > -1) {
  233. return true;
  234. } else {
  235. return false;
  236. }
  237. });
  238. item.children = children;
  239. return true;
  240. } else {
  241. return true;
  242. }
  243. } else {
  244. return false;
  245. }
  246. });
  247. this.$store.commit("setMenuListTotal", list);
  248. },
  249. //
  250. permissionFilteringUnlogin() {
  251. this.permissionFiltering(this.permissionUnlogin);
  252. },
  253. // 访问接口反馈
  254. checkRequestCode(result) {
  255. let that = this;
  256. return new Promise((resolve, reject) => {
  257. if (result.code == 212) {
  258. let obj = that.getParams();
  259. let autologin1 = obj.autologin;
  260. let autologin2 = localStorage.getItem("autologin");
  261. if (
  262. autologin1 == 1 ||
  263. autologin2 != null ||
  264. autologin2 != undefined
  265. ) {
  266. that.loginFunc();
  267. } else {
  268. that.$store.commit("setToken", "");
  269. that.$store.commit("setUserState", false);
  270. }
  271. } else {
  272. let code = that.requestCode[result.code];
  273. if (code == 206 || code == 207 || code == 208) {
  274. this.$router.push({
  275. path: "/error",
  276. });
  277. } else {
  278. that.$message({
  279. type: "warning",
  280. message: that.requestCode[result.code],
  281. });
  282. }
  283. }
  284. });
  285. },
  286. // 获取url参数
  287. getQueryString(name) {
  288. var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
  289. var r = window.location.search.substr(1).match(reg);
  290. if (r != null) return unescape(r[2]);
  291. return null;
  292. },
  293. // 获取图层
  294. getMenu() {
  295. let that = this;
  296. general
  297. .getLayerList()
  298. .then(function (result) {
  299. if (result.code == 200) {
  300. that.$store.commit("setLayerList", result.content);
  301. } else {
  302. checkRequestCode(result);
  303. }
  304. })
  305. .catch((err) => {
  306. that.$message({
  307. type: "error",
  308. message: err,
  309. });
  310. });
  311. },
  312. // 获取icon
  313. getIcon() {
  314. let that = this;
  315. icon
  316. .getIcon()
  317. .then((result) => {
  318. if (result.code == 200) {
  319. that.$store.commit("setIconList", result.content);
  320. } else {
  321. result.message = "标注图片获取失败,请重试!";
  322. checkRequestCode(result);
  323. }
  324. })
  325. .catch((err) => {
  326. that.$message({
  327. type: "error",
  328. message: err,
  329. });
  330. });
  331. },
  332. },
  333. };
  334. </script>
  335. <style lang="less" scoped>
  336. .home {
  337. height: 100%;
  338. width: 100%;
  339. }
  340. .el-container {
  341. height: 100%;
  342. }
  343. .router_container {
  344. height: calc(100% - @header_height);
  345. }
  346. .el-header {
  347. padding: 0 0;
  348. height: @header_height !important;
  349. box-shadow: 0px 0px 5px 0px rgba(0, 0, 0, 0.12);
  350. z-index: 1;
  351. .banner {
  352. height: 200px;
  353. width: 100%;
  354. position: relative;
  355. background: url(~@/assets/images/banner.png);
  356. .login_content {
  357. position: absolute;
  358. top: 20px;
  359. right: 50px;
  360. font-size: 16px;
  361. color: #ffffff;
  362. .before_login {
  363. .el-input {
  364. width: 150px;
  365. height: 30px;
  366. line-height: 30px;
  367. margin-right: 10px;
  368. /deep/ .el-input__inner {
  369. height: 30px;
  370. line-height: 30px;
  371. background: #ffffff33;
  372. border: 0px;
  373. color: #ffffff;
  374. &::-webkit-input-placeholder {
  375. color: #ffffff;
  376. }
  377. &::-moz-placeholder {
  378. color: #ffffff;
  379. }
  380. &:-ms-input-placeholder {
  381. color: #ffffff;
  382. }
  383. &::-webkit-input-placeholder {
  384. color: #ffffff;
  385. }
  386. &::placeholder {
  387. color: #ffffff;
  388. }
  389. }
  390. /deep/ .el-input__clear {
  391. line-height: 30px;
  392. color: #e3e3e3;
  393. &:hover {
  394. color: #ffffff;
  395. }
  396. }
  397. }
  398. .el-button {
  399. height: 30px;
  400. width: 60px;
  401. padding: 0 10px;
  402. background: #ffcc42; //#ffcc42
  403. color: #ffffff;
  404. border: 0px;
  405. font-size: 16px;
  406. vertical-align: bottom;
  407. &:hover {
  408. background: #ffc21c;
  409. }
  410. }
  411. }
  412. .after_login {
  413. .el-button {
  414. height: 30px;
  415. width: 60px;
  416. padding: 0 10px;
  417. background: #ffcc42; //#ffcc42
  418. color: #ffffff;
  419. border: 0px;
  420. font-size: 16px;
  421. margin-left: 20px;
  422. &:hover {
  423. background: #ffc21c;
  424. }
  425. }
  426. }
  427. }
  428. }
  429. .func {
  430. height: 60px;
  431. background: #40a2ff;
  432. .el-menu {
  433. background: transparent;
  434. width: fit-content;
  435. margin: 0 auto;
  436. border-bottom: 0px;
  437. .el-menu-item {
  438. font-family: Source Han Sans CN VF;
  439. font-size: 20px;
  440. color: #ffffff;
  441. width: 180px;
  442. text-align: center;
  443. border-bottom-color: transparent;
  444. &.is-active {
  445. font-weight: bold;
  446. background: transparent;
  447. }
  448. &:hover {
  449. font-weight: bold;
  450. background: transparent;
  451. }
  452. }
  453. }
  454. }
  455. }
  456. .el-main {
  457. padding: 0 0;
  458. background: #f9f9f9;
  459. padding: 30px 200px;
  460. }
  461. </style>