index.vue 19 KB

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