Topmenu.vue 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. <template>
  2. <div class="Topmenu">
  3. <div class="TopmenuPir">
  4. <div class="TopmenuPir-logo">
  5. <div class="TopmenuPir-logo1">
  6. <img src="@/assets/img/logo2-1.png" alt="logo">
  7. </div>
  8. <div class="TopmenuPir-logo2">
  9. <img src="@/assets/img/logo2-2.png" alt="logo">
  10. </div>
  11. </div>
  12. <div class="TopmenuPir-mai">
  13. <div class="TopmenuPir-mai-ul">
  14. <el-popover placement="top-start" title="系统消息" trigger="hover" content="接收系统下发的新消息">
  15. <div slot="reference" class="TopmenuPir-mai-ul-li" @click="SetMenu(1)">
  16. <i class="el-icon-bell" style="font-size: 26px;"></i>
  17. </div>
  18. </el-popover>
  19. <el-popover placement="top-start" title="更换主题" trigger="hover" content="更改系统整体风格,字体颜色,背景色等等">
  20. <div slot="reference" class="TopmenuPir-mai-ul-li" @click="SetMenu(2)">
  21. <i class="el-icon-magic-stick" style="font-size: 26px;"></i>
  22. </div>
  23. </el-popover>
  24. <el-popover placement="top-start" title="全屏/正常模式" trigger="hover" content="切换全屏或者正常展示模式">
  25. <div slot="reference" class="TopmenuPir-mai-ul-li" @click="quan"><i class="el-icon-monitor"
  26. style="font-size: 26px;"></i></div>
  27. </el-popover>
  28. <div class="TopmenuPir-mai-ul-li">
  29. <el-dropdown @command="commands">
  30. <div class="el-dropdown-link dropdown-links" style="">
  31. <i class="el-icon-user" style="font-size: 26px;"></i>
  32. </div>
  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-item command="c">修改密码</el-dropdown-item>
  37. <el-dropdown-item command="d">退出登录</el-dropdown-item>
  38. </el-dropdown-menu>
  39. </el-dropdown>
  40. </div>
  41. </div>
  42. </div>
  43. </div>
  44. <el-dialog title="修改密码" :visible.sync="dialogVisible" width="400px" :close-on-click-modal="false">
  45. <el-form :model="ruleForm" status-icon :rules="rules" ref="ruleForm" class="demo-ruleForm">
  46. <el-form-item label="旧密码" prop="T_oldpass">
  47. <el-input type="password" v-model="ruleForm.T_oldpass" show-password></el-input>
  48. </el-form-item>
  49. <el-form-item label="新密码" prop="T_pass">
  50. <el-input type="password" v-model="ruleForm.T_pass" show-password></el-input>
  51. </el-form-item>
  52. </el-form>
  53. <div slot="footer" class="dialog-footer">
  54. <el-button @click="dialogVisible = false">取 消</el-button>
  55. <el-button type="primary" @click="submitForm('ruleForm')"">提 交</el-button>
  56. </div>
  57. </el-dialog>
  58. </div>
  59. </template>
  60. <script>
  61. import { UserUpPass,AdminUpPass } from "@/api/home.js";
  62. export default {
  63. data() {
  64. return {
  65. dialogVisible:false,
  66. ruleForm: {
  67. T_pass:'',//新密码
  68. T_passstr: '',//明文 用户端要传,管理员端可不传
  69. T_oldpass: ''//旧密码
  70. },
  71. rules: {
  72. T_pass: [
  73. { required: true, message: '请输入新密码', trigger: ['change','blur']},
  74. { min: 6, max: 18, message: '新密码长度在 6到 18 位', trigger: ['change','blur'] }
  75. ],
  76. T_oldpass: [
  77. { required: true, message: '请输入旧密码', trigger: ['change','blur'] },
  78. { min: 6, max: 18, message: '旧密码长度在 6 到 18 位', trigger: ['change','blur'] }
  79. ],
  80. }
  81. }
  82. },
  83. methods: {
  84. submitForm(formName) {
  85. this.$refs[formName].validate((valid) => {
  86. if (valid) {
  87. let rules = this.$store.state.userInfo.value
  88. if (rules==1) {//管理员
  89. let initParam = {
  90. T_pass:this.$md5(this.ruleForm.T_pass),
  91. T_oldpass:this.$md5(this.ruleForm.T_oldpass),
  92. }
  93. this.resetRequest(rules,initParam)
  94. }else{//用户
  95. let initParam = {
  96. T_pass:this.$md5(this.ruleForm.T_pass),
  97. T_passstr:this.ruleForm.T_pass,
  98. T_oldpass:this.$md5(this.ruleForm.T_oldpass),
  99. }
  100. this.resetRequest(rules,initParam)
  101. }
  102. } else {
  103. return false;
  104. }
  105. });
  106. },
  107. async resetRequest(rules,initParam){
  108. const {data:result} = rules==1?await AdminUpPass(initParam): await UserUpPass(initParam)
  109. if(result.Code==200){
  110. this.$store.commit('setuserInfo', {
  111. username: '',
  112. password: '',
  113. value:'2',
  114. token:''
  115. })
  116. this.$message.success('重置密码成功')
  117. setTimeout(()=>this.$router.replace('/'), 1000)
  118. }
  119. },
  120. resetForm(formName) {
  121. if(this.$refs[formName])this.$refs[formName].resetFields();
  122. },
  123. SetMenu(e) {
  124. this.$notify.info({
  125. title: '错误提示',
  126. message: '功能正在更新中,敬请留意',
  127. offset: 100
  128. });
  129. },
  130. commands(e) {
  131. switch (e) {
  132. case 'a':
  133. this.$notify.info({
  134. title: '错误提示',
  135. message: '功能正在更新中,敬请留意',
  136. offset: 100
  137. });
  138. break
  139. case 'b':
  140. this.$notify.info({
  141. title: '错误提示',
  142. message: '功能正在更新中,敬请留意',
  143. offset: 100
  144. });
  145. break
  146. case 'c':
  147. this.dialogVisible = true
  148. this.resetForm('ruleForm')
  149. break
  150. default:
  151. this.$router.replace('/')
  152. }
  153. },
  154. quan() {//全屏
  155. if (window.innerHeight === window.screen.height) { // 利用屏幕分辨率和window对象的内高度来判断兼容IE
  156. document.exitFullscreen()
  157. } else {
  158. document.documentElement.requestFullscreen()
  159. }
  160. },
  161. }
  162. }
  163. </script>
  164. <style lang="scss">
  165. .Topmenu {
  166. background-color: #3a394e;
  167. height: 60px;
  168. color: #fff;
  169. .TopmenuPir {
  170. display: flex;
  171. justify-content: space-between;
  172. align-items: center;
  173. height: 100%;
  174. padding-right: 0 15px;
  175. .TopmenuPir-mai {
  176. color: #fff !important;
  177. .TopmenuPir-mai-ul {
  178. display: flex;
  179. align-items: center;
  180. .TopmenuPir-mai-ul-li {
  181. margin-right: 30px;
  182. cursor: pointer;
  183. .dropdown-links {
  184. width: 30px;
  185. height: 30px;
  186. background: #fff;
  187. border-radius: 50%;
  188. display: flex;
  189. align-items: center;
  190. justify-content: center;
  191. outline: none;
  192. }
  193. }
  194. }
  195. }
  196. .TopmenuPir-logo {
  197. height: 60px;
  198. display: flex;
  199. align-items: center;
  200. .TopmenuPir-logo1 {
  201. width: 80px;
  202. height: 80px;
  203. display: flex;
  204. justify-content: center;
  205. align-items: center;
  206. // background: #fff;
  207. img {
  208. width: 60%;
  209. height: 60%;
  210. object-fit: contain;
  211. }
  212. }
  213. .TopmenuPir-logo2 {
  214. height: 60px;
  215. display: flex;
  216. margin-left: 10px;
  217. align-items: center;
  218. img {
  219. width: auto;
  220. height: 100%;
  221. }
  222. }
  223. }
  224. }
  225. }
  226. </style>