index.vue 7.8 KB

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