index.vue 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. <template>
  2. <div class="home">
  3. <div class="menu-box"></div>
  4. <el-dialog :visible.sync="dialogFormVisible" :close-on-click-modal="false" :show-close="false" width="600px" custom-class="customClass">
  5. <div slot="title" class="dialog-title">
  6. <el-row>
  7. <el-icon class="el-icon-message-solid"></el-icon>
  8. <span>请先修改密码,再登录系统</span>
  9. </el-row>
  10. </div>
  11. <el-form :model="dialogForm" :rules="rules" ref="dialogForm" label-position="right"
  12. label-width="110px"
  13. style="width: 400px; margin-left:50px;">
  14. <el-form-item label="原密码" prop="originalPassword" :rules="{required: true, message: '请输入原密码', trigger: 'blur'}">
  15. <el-input v-model="dialogForm.originalPassword" type="password" autocomplete="off"/>
  16. </el-form-item>
  17. <el-form-item label="新密码" prop="currentPassword" :rules="{required: true, message: '请输入新密码', trigger: 'blur'}">
  18. <el-input v-model="dialogForm.currentPassword" type="password" autocomplete="off"/>
  19. </el-form-item>
  20. <el-form-item label="确认密码" prop="repeatPassword" :rules="{required: true, message: '请输入确认密码', trigger: 'blur'}">
  21. <el-input v-model="dialogForm.repeatPassword" type="password" autocomplete="off"/>
  22. </el-form-item>
  23. </el-form>
  24. <div slot="footer" class="dialog-footer">
  25. <el-button @click="notChagePsw()">暂不修改</el-button>
  26. <el-button type="primary" @click="savePass('dialogForm')">修 改</el-button>
  27. </div>
  28. </el-dialog>
  29. </div>
  30. </template>
  31. <script>
  32. import { mapGetters } from 'vuex'
  33. export default {
  34. name: 'Home',
  35. components: {},
  36. data() {
  37. return {
  38. activeItem: {},
  39. dialogFormVisible:false,
  40. dialogForm:{},
  41. rules:{},
  42. }
  43. },
  44. computed: {
  45. ...mapGetters([
  46. 'permission_menus'
  47. ]),
  48. },
  49. watch: {
  50. permission_menus: {
  51. immediate: true, // immediate选项可以开启首次赋值监听
  52. deep: true,
  53. handler(newv) {
  54. if (newv && newv.length) {
  55. const pswState = this.$store.getters.userInfo.passwordState;
  56. this.dialogFormVisible = pswState;
  57. this.activeItem = newv[0];
  58. if (!this.dialogFormVisible){
  59. this.jumpMenu(this.activeItem)
  60. }
  61. }
  62. }
  63. },
  64. },
  65. created() {
  66. },
  67. methods: {
  68. menusClick(item) {
  69. this.activeItem = item
  70. },
  71. jumpMenu(mn) {
  72. // 跳转涉及到 menuTree.vue PermissionButton.vue login
  73. let jumpItem = null
  74. function tree(data) {
  75. if (jumpItem) {
  76. return
  77. }
  78. if (data.menuType === '菜单' && data.pcUrl) {
  79. jumpItem = data
  80. } else {
  81. if (data.children && data.children.length > 0) {
  82. data.children.forEach(item => {
  83. tree(item)
  84. })
  85. }
  86. }
  87. }
  88. tree(mn)
  89. // console.log(jumpItem, 'jumpItem')
  90. if (jumpItem && jumpItem.pcUrl) {
  91. if (jumpItem.external) {
  92. if (jumpItem.ifNewTag === false) { // 当前页面
  93. this.$router.push({
  94. path: jumpItem.pcUrl,
  95. query: {
  96. link: jumpItem.outerUrl?encodeURIComponent(jumpItem.outerUrl):''
  97. }
  98. })
  99. } else { // true 或未设置(兼容以前未设置的情况) 新开页面
  100. window.open(jumpItem.outerUrl)
  101. }
  102. } else {
  103. if (jumpItem.ifNewTag) { // 必须设为新开才新开,其他都是在当前页面。和上面相反
  104. this.$targetNewPage({
  105. path: jumpItem.pcUrl,
  106. query: {}
  107. })
  108. } else {
  109. this.$router.push({
  110. path: jumpItem.pcUrl,
  111. query: {}
  112. })
  113. }
  114. }
  115. } else {
  116. console.error(new Error('一级未找到菜单'))
  117. }
  118. },
  119. savePass(formName) {
  120. this.$refs[formName].validate((valid) => {
  121. if (valid) {
  122. if (this.dialogForm.currentPassword.length!=8){
  123. this.$notify({
  124. title: '错误',
  125. message: '新密码必须是8位字符',
  126. type: 'error',
  127. duration: 3000
  128. });
  129. return
  130. }
  131. if (this.dialogForm.currentPassword != this.dialogForm.repeatPassword){
  132. this.$notify({
  133. title: '错误',
  134. message: '两次输入的密码不一致,请检查。',
  135. type: 'error',
  136. duration: 3000
  137. });
  138. return
  139. }
  140. this.$api.user.modifyPass(this.dialogForm).then(res => {
  141. if (res.code === 200) {
  142. this.$notify({
  143. title: '成功',
  144. message: '密码修改成功,请重新登录.',
  145. type: 'success',
  146. duration: 10000
  147. });
  148. this.dialogFormVisible = false;
  149. setTimeout(() => {
  150. this.logout();
  151. }, 3000);
  152. }
  153. })
  154. } else {
  155. console.log('error submit!!')
  156. return false
  157. }
  158. })
  159. },
  160. async logout() {
  161. await this.$store.dispatch('user/logout');
  162. // this.$router.push(`/login?redirect=${this.$route.fullPath}`)
  163. this.$router.push(`/login`);
  164. },
  165. notChagePsw(){
  166. this.dialogFormVisible = false;
  167. this.jumpMenu(this.activeItem)
  168. }
  169. }
  170. }
  171. </script>
  172. <style lang="scss" scoped>
  173. .home {
  174. background-color: #f5f5f5;
  175. min-height: calc(100vh - 60px);
  176. min-width: 1200px;
  177. .menu-box {
  178. display: flex;
  179. background-color: #ffffff;
  180. margin: 0 50px 20px 50px;
  181. padding: 20px 0;
  182. .left {
  183. width: 240px;
  184. .menu-1-item {
  185. display: flex;
  186. align-items: center;
  187. color: #666666;
  188. width: 190px;
  189. height: 45px;
  190. font-weight: 500;
  191. color: rgba(101, 101, 101, 1);
  192. padding-left: 25px;
  193. font-size: 16px;
  194. cursor: pointer;
  195. padding-right: 10px;
  196. &.active {
  197. color: #ffffff;
  198. background: linear-gradient(90deg, rgba(0, 108, 255, 1), rgba(0, 168, 255, 1));
  199. border-radius: 0 10px 10px 0;
  200. }
  201. .text {
  202. margin-left: 10px;
  203. }
  204. }
  205. }
  206. .right {
  207. flex: 1;
  208. .title {
  209. font-size: 16px;
  210. font-weight: 500;
  211. color: rgba(51, 51, 51, 1);
  212. line-height: 35px;
  213. margin-bottom: 8px;
  214. &::before {
  215. content: '';
  216. display: inline-block;
  217. width: 5px;
  218. height: 16px;
  219. background: rgba(1, 141, 237, 1);
  220. margin-right: 10px;
  221. position: relative;
  222. top: 2px;
  223. }
  224. }
  225. .menu-2-box {
  226. display: flex;
  227. flex-wrap: wrap;
  228. }
  229. .menu-2-item {
  230. display: flex;
  231. align-items: center;
  232. color: #656565;
  233. font-size: 16px;
  234. width: 230px;
  235. height: 101px;
  236. background: rgba(255, 255, 255, 1);
  237. border-radius: 3px;
  238. padding-left: 20px;
  239. margin-right: 10px;
  240. margin-bottom: 10px;
  241. cursor: pointer;
  242. box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);
  243. .text {
  244. margin-left: 16px;
  245. }
  246. }
  247. }
  248. }
  249. }
  250. /deep/.customClass{
  251. border-radius: 20px;
  252. }
  253. .dialog-title{
  254. .el-icon-message-solid{
  255. font-size: 30px;
  256. color: red;
  257. }
  258. span{
  259. margin-left: 10px;
  260. color: red;
  261. font-size: 20px;
  262. }
  263. }
  264. </style>