index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. <!-- -->
  2. <template>
  3. <div
  4. class="indexbox"
  5. v-loading="indexloading"
  6. element-loading-text="欢迎登录大数据平台!加载中,请稍后..."
  7. element-loading-spinner="el-icon-loading"
  8. element-loading-background="rgba(255, 255, 255)"
  9. >
  10. <div class="menubox">
  11. <div class="index_title">
  12. <img
  13. v-if="imgurl"
  14. :src="
  15. imgurl.indexOf('http') == -1 ? this.$deriveData + imgurl : imgurl
  16. "
  17. alt=""
  18. class="menubox_logo_img"
  19. />
  20. <p>{{ headline }}</p>
  21. </div>
  22. <div class="index_out">
  23. <el-dropdown trigger="click" @command="quit">
  24. <span class="el-dropdown-link" style="cursor: pointer">
  25. <span>{{ username }}</span>
  26. <i class="el-icon-arrow-down el-icon--right"></i>
  27. </span>
  28. <el-dropdown-menu slot="dropdown">
  29. <el-dropdown-item command="a">更改密码</el-dropdown-item>
  30. <el-dropdown-item command="b">退出</el-dropdown-item>
  31. </el-dropdown-menu>
  32. </el-dropdown>
  33. <!-- <p><i class="el-icon-switch-button" @click="quit"></i></p> -->
  34. </div>
  35. </div>
  36. <div class="contentbox">
  37. <div class="menubox_item">
  38. <el-menu
  39. default-active="2"
  40. class="el-menu-vertical-demo"
  41. @open="handleOpen"
  42. background-color="#0D3756"
  43. text-color="#fff"
  44. :default-active="menuActiveId"
  45. active-text-color="#409EFF"
  46. :unique-opened="true"
  47. >
  48. <el-submenu
  49. v-for="item in infodata"
  50. :key="item.pur_id"
  51. :index="item.pur_id.toString()"
  52. >
  53. <template slot="title">
  54. <i class="el-icon-collection-tag"></i>
  55. <span>{{ item.purview_name }}</span>
  56. </template>
  57. <template v-for="items in item.children">
  58. <el-submenu
  59. :index="items.pur_id.toString()"
  60. v-if="items.children"
  61. :key="items.pur_id"
  62. @click="skip('/index/' + items.menu)"
  63. >
  64. <span slot="title">{{ items.purview_name }}</span>
  65. <el-menu-item-group>
  66. <el-menu-item
  67. v-for="item2 in items.children"
  68. :index="item2.pur_id.toString()"
  69. :key="item2.pur_id"
  70. @click="skip('/index/' + item2.menu)"
  71. >
  72. <span slot="title">{{ item2.purview_name }}</span>
  73. </el-menu-item>
  74. </el-menu-item-group>
  75. </el-submenu>
  76. <el-menu-item
  77. :index="items.pur_id.toString()"
  78. v-else
  79. :key="items.pur_id"
  80. @click="skip('/index/' + items.menu)"
  81. class="el-menu-item2"
  82. >
  83. <span slot="title"> {{ items.purview_name }}</span>
  84. </el-menu-item>
  85. </template>
  86. </el-submenu>
  87. </el-menu>
  88. </div>
  89. <div class="contentbox_right">
  90. <div class="contentbox_crumbs">
  91. <el-breadcrumb separator="/">
  92. <el-breadcrumb-item
  93. v-for="(item, index) in routerinfo"
  94. :key="item.pur_id"
  95. ><a
  96. v-if="index == routerinfo.length - 2 && item.menu != ''&&item.purview_name!='查看图片'"
  97. :href="'/#/index/' + item.menu"
  98. style="cursor: pointer"
  99. >{{ item.purview_name }}</a
  100. ><span v-else>{{ item.purview_name }}</span></el-breadcrumb-item
  101. >
  102. </el-breadcrumb>
  103. </div>
  104. <div class="contentbox_box">
  105. <router-view />
  106. </div>
  107. </div>
  108. </div>
  109. <el-dialog
  110. title="提示"
  111. :visible.sync="alterpassTF"
  112. width="500px"
  113. :before-close="handleClose"
  114. >
  115. <div>
  116. <el-form
  117. :model="ruleForm"
  118. :rules="rules"
  119. ref="ruleForm"
  120. label-width="110px"
  121. class="demo-ruleForm"
  122. >
  123. <el-form-item label="原始密码:" prop="oldpass">
  124. <el-input type="password" v-model="ruleForm.oldpass"></el-input>
  125. </el-form-item>
  126. <el-form-item label="新密码:" prop="newpass">
  127. <el-input type="password" v-model="ruleForm.newpass"></el-input>
  128. </el-form-item>
  129. <el-form-item label="确认新密码:" prop="newpasstrue">
  130. <el-input type="password" v-model="ruleForm.newpasstrue"></el-input>
  131. </el-form-item>
  132. </el-form>
  133. </div>
  134. <span slot="footer" class="dialog-footer">
  135. <el-button @click="resetForm('ruleForm')" size="mini">取 消</el-button>
  136. <el-button type="primary" @click="submitForm('ruleForm')" size="mini"
  137. >确 定</el-button
  138. >
  139. </span>
  140. </el-dialog>
  141. </div>
  142. </template>
  143. <script>
  144. //这里可以导入其他文件(比如:组件,工具js,第三方插件js,json文件,图片文件等等)
  145. export default {
  146. //import引入的组件需要注入到对象中才能使用
  147. components: {},
  148. data() {
  149. //这里存放数据
  150. var validatePass = (rule, value, callback) => {
  151. console.log(value);
  152. if (value == this.ruleForm.newpass) {
  153. callback();
  154. } else {
  155. callback(new Error("俩次密码不一致,请重新确认密码!"));
  156. }
  157. };
  158. return {
  159. infodata: [],
  160. username: "",
  161. routerdata: [],
  162. menuActiveId: "1",
  163. // menuOpeneds:["18"]
  164. routerinfo: [],
  165. options: [],
  166. value: "",
  167. imgurl: "", //系统logo
  168. headline: "", //系统标题
  169. alterpassTF: false, //修改密码框
  170. ruleForm: {
  171. oldpass: "",
  172. newpass: "",
  173. newpasstrue: "",
  174. },
  175. rules: {
  176. oldpass: [
  177. { required: true, message: "请输入原始密码", trigger: "blur" },
  178. {
  179. min: 6,
  180. max: 15,
  181. message: "长度在 6 到 15 个字符",
  182. trigger: "blur",
  183. },
  184. ],
  185. newpass: [
  186. { required: true, message: "请输入新密码", trigger: "blur" },
  187. {
  188. min: 6,
  189. max: 15,
  190. message: "长度在 6 到 15 个字符",
  191. trigger: "blur",
  192. },
  193. ],
  194. newpasstrue: [
  195. { required: true, message: "请再次输入新密码", trigger: "blur" },
  196. {
  197. min: 6,
  198. max: 15,
  199. message: "长度在 6 到 15 个字符",
  200. trigger: "blur",
  201. },
  202. { validator: validatePass, trigger: "blur" },
  203. ],
  204. },
  205. indexloading: false,
  206. pur_id: "",
  207. };
  208. },
  209. //监听属性 类似于data概念
  210. computed: {},
  211. //监控data中的数据变化
  212. watch: {
  213. "$route.path": function (newVal) {
  214. console.log(newVal);
  215. this.routemap(this.routerdata);
  216. // this.menuActiveId = this.$route.path;
  217. },
  218. },
  219. //方法集合
  220. methods: {
  221. handleOpen(e) {
  222. console.log(e);
  223. // localStorage.setItem("menuActiveId", e);
  224. },
  225. handleClose() {},
  226. // user.login.user_login_info
  227. getuserinfo() {
  228. this.indexloading = true;
  229. this.$axios({
  230. method: "POST",
  231. url: "/api/api_gateway?method=sysmenage.usermanager.user_info",
  232. }).then((res) => {
  233. this.indexloading = false;
  234. this.imgurl = res.data.data.theme_info.logo_url;
  235. this.headline = res.data.data.theme_info.sys_name;
  236. this.routerdata = JSON.parse(JSON.stringify(res.data.data.children));
  237. this.infodata = res.data.data.children;
  238. console.log(this.routerdata);
  239. // this.infodata.shift();
  240. localStorage.setItem("userID", res.data.data.im_user_id); // 存储当前登录账号的ID
  241. this.username = res.data.data.username;
  242. localStorage.setItem("usernme", this.username);
  243. this.routemap(this.routerdata);
  244. });
  245. },
  246. quit(e) {
  247. // user.login.logout_user
  248. console.log(e);
  249. if (e == "a") {
  250. this.alterpassTF = true;
  251. } else if (e == "b") {
  252. this.outsystem();
  253. }
  254. },
  255. outsystem() {
  256. this.$axios({
  257. method: "POST",
  258. url: "/api/api_gateway?method=sysmenage.usermanager.user_logout",
  259. }).then((res) => {
  260. if (res.data.data) {
  261. localStorage.removeItem("session");
  262. localStorage.removeItem("username");
  263. this.$router.push("/Login");
  264. }
  265. });
  266. },
  267. skip(path) {
  268. // console.log(this.$route);ssssss
  269. if (this.$route.path != path) {
  270. this.$router.push(path);
  271. }
  272. },
  273. submitForm(formName) {
  274. this.$refs[formName].validate((valid) => {
  275. if (valid) {
  276. this.$axios({
  277. method: "POST",
  278. url: "/api/api_gateway?method=app.my.app_change_pwd",
  279. data: this.qs.stringify({
  280. old_password: this.ruleForm.oldpass, // 必传 旧密码
  281. new_password: this.ruleForm.newpass, // 必传 新密码
  282. confirm_password: this.ruleForm.newpasstrue, // 必传 再次确认新密码
  283. }),
  284. }).then((res) => {
  285. if (res.data.data) {
  286. this.alterpassTF = false;
  287. if (document.getElementsByClassName("el-message").length == 0) {
  288. this.$message({
  289. message: "修改成功!",
  290. type: "success",
  291. });
  292. }
  293. this.outsystem();
  294. } else {
  295. if (document.getElementsByClassName("el-message").length == 0) {
  296. this.$message({
  297. message: "修改失败!" + res.data.data.message,
  298. type: "error",
  299. });
  300. }
  301. }
  302. });
  303. } else {
  304. if (document.getElementsByClassName("el-message").length == 0) {
  305. this.$message({
  306. message: "请完成信息填写!",
  307. type: "warning",
  308. });
  309. }
  310. return false;
  311. }
  312. });
  313. },
  314. resetForm(formName) {
  315. this.$refs[formName].resetFields();
  316. this.alterpassTF = false;
  317. },
  318. routemap(routerdata) {
  319. var newrouter = this.$route.path;
  320. var tf = routerdata.filter((item) => {
  321. if (item.menu != "") {
  322. if (newrouter.indexOf(item.menu) != -1) {
  323. // 第一层菜单是否包含当前路由
  324. // var arr = [item.menu,item.pur_id]
  325. // console.log(item.pur_id)
  326. // return arr
  327. // var a = '111111111'
  328. return [item.menu, item.pur_id];
  329. } else {
  330. if (item.children) {
  331. this.routemap(item.children);
  332. }
  333. }
  334. } else {
  335. if (item.children) {
  336. this.routemap(item.children);
  337. }
  338. }
  339. });
  340. // console.log(tf)
  341. if (tf.length != 0) {
  342. console.log(tf);
  343. // this.menuActiveId = tf[0].pur_id.toString();
  344. this.routerinfo = [];
  345. this.routerinfo.unshift(tf[0]);
  346. var newpath = this.routerdata.filter((item) => {
  347. // console.log(item)
  348. if (item.pur_id == tf[0].parent_perm_id) {
  349. return item.pur_id == tf[0].parent_perm_id;
  350. } else {
  351. var newpath2 = item.children.filter((items) => {
  352. if (items.pur_id == tf[0].parent_perm_id) {
  353. return items.pur_id == tf[0].parent_perm_id;
  354. } else {
  355. if (items.children) {
  356. var newpath3 = items.children.filter((itemsa) => {
  357. // console.log(itemsa.pur_id,tf[0].parent_perm_id)
  358. if (itemsa.pur_id == tf[0].parent_perm_id) {
  359. return itemsa.pur_id == tf[0].parent_perm_id;
  360. } else {
  361. // console.log(itemsa)
  362. if (itemsa.children) {
  363. var newpath4 = itemsa.children.filter((itemsaa) => {
  364. if (itemsaa.pur_id == tf[0].parent_perm_id) {
  365. return itemsaa.pur_id == tf[0].parent_perm_id;
  366. } else {
  367. }
  368. });
  369. console.log(newpath4);
  370. if (newpath4.length != 0) {
  371. this.routerinfo.unshift(newpath4[0]);
  372. return newpath4;
  373. }
  374. }
  375. }
  376. });
  377. if (newpath3.length != 0) {
  378. this.routerinfo.unshift(newpath3[0]);
  379. return newpath3;
  380. }
  381. }
  382. }
  383. // return items.pur_id == tf[0].parent_perm_id;
  384. });
  385. if (newpath2.length != 0) {
  386. this.routerinfo.unshift(newpath2[0]);
  387. return newpath2;
  388. }
  389. }
  390. });
  391. // console.log(newpath)
  392. this.routerinfo.unshift(newpath[0]);
  393. console.log(this.routerinfo);
  394. } else {
  395. // console.log(this.routerinfo);
  396. var obj = {
  397. menu: "",
  398. parent_perm_id: "88",
  399. pur_id: "88",
  400. purview_name: "查看详情",
  401. };
  402. if (this.routerinfo[1] && !this.routerinfo[2]) {
  403. if (this.$route.path == "/index/taskRegulatorDetails") {
  404. this.routerinfo.push(obj);
  405. } else if (this.$route.path == "/index/superviseAdminDetails") {
  406. this.routerinfo.push(obj);
  407. } else if (this.$route.path == "/index/superviseDetails") {
  408. this.routerinfo.push(obj);
  409. } else if (this.$route.path == "/index/superviseLogDetails") {
  410. this.routerinfo.push(obj);
  411. }
  412. }
  413. }
  414. },
  415. },
  416. beforeCreate() {}, //生命周期 - 创建之前
  417. //生命周期 - 创建完成(可以访问当前this实例)
  418. created() {},
  419. beforeMount() {}, //生命周期 - 挂载之前
  420. //生命周期 - 挂载完成(可以访问DOM元素)
  421. mounted() {
  422. // this.menuActiveId = localStorage.getItem("menuActiveId");
  423. this.getuserinfo();
  424. },
  425. beforeUpdate() {}, //生命周期 - 更新之前
  426. updated() {}, //生命周期 - 更新之后
  427. beforeDestroy() {}, //生命周期 - 销毁之前
  428. destroyed() {}, //生命周期 - 销毁完成
  429. activated() {}, //如果页面有keep-alive缓存功能,这个函数会触发
  430. };
  431. </script>
  432. <style lang="less" scoped>
  433. p {
  434. margin: 0;
  435. }
  436. .indexbox {
  437. // display: flex;
  438. }
  439. .menubox {
  440. width: 100%;
  441. display: flex;
  442. height: 62px;
  443. line-height: 62px;
  444. justify-content: space-between;
  445. padding: 0 15px;
  446. box-sizing: border-box;
  447. background-color: #fff;
  448. box-shadow: 0 2px 3px -1px rgb(224, 219, 219); //底部阴影
  449. .index_title {
  450. display: flex;
  451. .menubox_logo_img {
  452. width: 40px;
  453. height: 40px;
  454. margin: 11px;
  455. }
  456. p {
  457. font-size: 18px;
  458. font-weight: 700;
  459. }
  460. }
  461. }
  462. .contentbox {
  463. // width: calc(100% - 240px);
  464. display: flex;
  465. .menubox_item {
  466. height: calc(100vh - 62px);
  467. background-color: #0d3756;
  468. overflow-y: auto;
  469. width: 226px;
  470. /deep/.el-menu {
  471. border: 0;
  472. }
  473. /deep/.el-menu-vertical-demo {
  474. width: 220px;
  475. }
  476. /deep/.el-submenu__title {
  477. text-align: left;
  478. // padding-left: 67px !important;
  479. }
  480. /deep/.el-menu--inline {
  481. .el-submenu__title {
  482. text-align: left;
  483. padding-left: 67px !important;
  484. }
  485. .el-menu-item {
  486. padding-left: 80px !important;
  487. }
  488. }
  489. /deep/.el-submenu__title:hover {
  490. color: rgb(64, 158, 255) !important;
  491. background-color: rgba(0, 0, 0, 0.3) !important;
  492. }
  493. /deep/.is-opened > .el-submenu__title {
  494. background-color: rgba(0, 0, 0, 0.3) !important;
  495. }
  496. /deep/.is-active {
  497. background-color: rgba(0, 0, 0, 0.3) !important;
  498. }
  499. /deep/.el-menu-item {
  500. text-align: left;
  501. // background-color: rgba(0, 0, 0, 0.3) !important;
  502. }
  503. /deep/.el-menu-item:hover {
  504. color: rgb(64, 158, 255) !important;
  505. }
  506. /deep/.el-menu--inline > .el-menu-item2 {
  507. padding-left: 67px !important;
  508. background-color: transparent !important;
  509. }
  510. /deep/.el-menu-item-group__title {
  511. display: none;
  512. }
  513. /deep/.el-icon-arrow-down:before {
  514. content: "\E6DF";
  515. color: #fff;
  516. font-size: 16px;
  517. }
  518. .firstmenu {
  519. text-align: left;
  520. padding-left: 20px !important;
  521. }
  522. }
  523. /*滚动条样式*/
  524. ::-webkit-scrollbar {
  525. width: 6px;
  526. // margin-left: -1px;
  527. /*height: 4px;*/
  528. }
  529. ::-webkit-scrollbar-thumb {
  530. border-radius: 10px;
  531. -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
  532. background: rgba(0, 0, 0, 0.1);
  533. }
  534. ::-webkit-scrollbar-track {
  535. border-radius: 10px;
  536. -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.1);
  537. // border-radius: 0;
  538. background: rgba(0, 0, 0, 0.1);
  539. }
  540. .contentbox_right {
  541. width: calc(100% - 226px);
  542. margin: 10px auto 0;
  543. .contentbox_crumbs {
  544. width: 98%;
  545. margin: 0;
  546. /deep/.el-breadcrumb {
  547. margin: 0 0 0 20px;
  548. padding: 0 !important;
  549. background-color: transparent !important;
  550. }
  551. }
  552. .contentbox_box {
  553. width: 98%;
  554. height: calc(100vh - 100px);
  555. // background-color: chartreuse;
  556. margin: 15px auto 0;
  557. overflow-y: auto;
  558. }
  559. }
  560. }
  561. </style>