index.vue 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  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 type='success' @click="notRemind()">不再提示</el-button>
  25. <el-button type="warning" @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. notRemind(){
  170. this.$api.user.notRemind().then(res=>{
  171. if (res.code ===200 && res.data){
  172. console.log("Not remind successful")
  173. }
  174. });
  175. this.dialogFormVisible = false;
  176. this.jumpMenu(this.activeItem)
  177. }
  178. }
  179. }
  180. </script>
  181. <style lang="scss" scoped>
  182. .home {
  183. background-color: #f5f5f5;
  184. min-height: calc(100vh - 60px);
  185. min-width: 1200px;
  186. .menu-box {
  187. display: flex;
  188. background-color: #ffffff;
  189. margin: 0 50px 20px 50px;
  190. padding: 20px 0;
  191. .left {
  192. width: 240px;
  193. .menu-1-item {
  194. display: flex;
  195. align-items: center;
  196. color: #666666;
  197. width: 190px;
  198. height: 45px;
  199. font-weight: 500;
  200. color: rgba(101, 101, 101, 1);
  201. padding-left: 25px;
  202. font-size: 16px;
  203. cursor: pointer;
  204. padding-right: 10px;
  205. &.active {
  206. color: #ffffff;
  207. background: linear-gradient(90deg, rgba(0, 108, 255, 1), rgba(0, 168, 255, 1));
  208. border-radius: 0 10px 10px 0;
  209. }
  210. .text {
  211. margin-left: 10px;
  212. }
  213. }
  214. }
  215. .right {
  216. flex: 1;
  217. .title {
  218. font-size: 16px;
  219. font-weight: 500;
  220. color: rgba(51, 51, 51, 1);
  221. line-height: 35px;
  222. margin-bottom: 8px;
  223. &::before {
  224. content: '';
  225. display: inline-block;
  226. width: 5px;
  227. height: 16px;
  228. background: rgba(1, 141, 237, 1);
  229. margin-right: 10px;
  230. position: relative;
  231. top: 2px;
  232. }
  233. }
  234. .menu-2-box {
  235. display: flex;
  236. flex-wrap: wrap;
  237. }
  238. .menu-2-item {
  239. display: flex;
  240. align-items: center;
  241. color: #656565;
  242. font-size: 16px;
  243. width: 230px;
  244. height: 101px;
  245. background: rgba(255, 255, 255, 1);
  246. border-radius: 3px;
  247. padding-left: 20px;
  248. margin-right: 10px;
  249. margin-bottom: 10px;
  250. cursor: pointer;
  251. box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04);
  252. .text {
  253. margin-left: 16px;
  254. }
  255. }
  256. }
  257. }
  258. }
  259. /deep/.customClass{
  260. border-radius: 20px;
  261. }
  262. .dialog-title{
  263. .el-icon-message-solid{
  264. font-size: 30px;
  265. color: red;
  266. }
  267. span{
  268. margin-left: 10px;
  269. color: red;
  270. font-size: 20px;
  271. }
  272. }
  273. </style>